refactor: move handleWebhookMessage into callback

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu 2023-11-17 17:27:49 +01:00
parent e6337cf6bd
commit 889ef8820a
No known key found for this signature in database
GPG key ID: E13DFD4B47127951

View file

@ -7,7 +7,6 @@ import {
PermissionFlagsBits, PermissionFlagsBits,
ChannelType, ChannelType,
Events, Events,
Message,
} from 'discord.js'; } from 'discord.js';
import { reuploadCommands } from './_reupload'; import { reuploadCommands } from './_reupload';
import { import {
@ -52,11 +51,6 @@ const client = new Client({
partials: [Partials.Channel], partials: [Partials.Channel],
}); });
const handleWebhookMessage = async (e: Message<boolean>) => {
const pkMessage = await fetchPluralKitMessage(e);
if (pkMessage !== null) storeUserPlurality(pkMessage.sender);
};
client.once('ready', async () => { client.once('ready', async () => {
console.log(green('Discord bot ready!')); console.log(green('Discord bot ready!'));
@ -107,7 +101,8 @@ client.once('ready', async () => {
if (e.webhookId !== null) { if (e.webhookId !== null) {
// defer PK detection // defer PK detection
setTimeout(async () => { setTimeout(async () => {
await handleWebhookMessage(e); const pkMessage = await fetchPluralKitMessage(e);
if (pkMessage !== null) storeUserPlurality(pkMessage.sender);
}, pkDelay); }, pkDelay);
} }