Skip to content

Commit

Permalink
refactor: move handleWebhookMessage into callback
Browse files Browse the repository at this point in the history
Signed-off-by: Sefa Eyeoglu <[email protected]>
  • Loading branch information
Scrumplex committed Nov 17, 2023
1 parent e6337cf commit 889ef88
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
PermissionFlagsBits,
ChannelType,
Events,
Message,
} from 'discord.js';
import { reuploadCommands } from './_reupload';
import {
Expand Down Expand Up @@ -52,11 +51,6 @@ const client = new Client({
partials: [Partials.Channel],
});

const handleWebhookMessage = async (e: Message<boolean>) => {
const pkMessage = await fetchPluralKitMessage(e);
if (pkMessage !== null) storeUserPlurality(pkMessage.sender);
};

client.once('ready', async () => {
console.log(green('Discord bot ready!'));

Expand Down Expand Up @@ -107,7 +101,8 @@ client.once('ready', async () => {
if (e.webhookId !== null) {
// defer PK detection
setTimeout(async () => {
await handleWebhookMessage(e);
const pkMessage = await fetchPluralKitMessage(e);
if (pkMessage !== null) storeUserPlurality(pkMessage.sender);
}, pkDelay);
}

Expand Down

0 comments on commit 889ef88

Please sign in to comment.