refactor: move handleWebhookMessage into callback
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
parent
e6337cf6bd
commit
889ef8820a
1 changed files with 2 additions and 7 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue