fix: possibly solve duplicate event 'interactionCreate' listener bug

This commit is contained in:
Marius Begby committed 2023-09-14 13:36:57 +02:00
1 parent 2d7ffc1a3f
commit 2d08a9aa85
1 file changed
+9
+9
View File
@@ -26,11 +26,20 @@ const logger: Logger = loggerModule.child({
const client: ExtendedClient = await createClient({ executionId });
const player: Player = await createPlayer({ client, executionId });
let allShardsReadyReceived: boolean = false;
client.on('allShardsReady', async () => {
if (allShardsReadyReceived) {
logger.debug('allShardsReady event received, but already received before. Ignoring.');
return;
}
logger.debug('allShardsReady event received, registering client interactions and event listeners.');
client.registerClientInteractions = registerClientInteractions;
await registerEventListeners({ client, player, executionId });
await registerClientInteractions({ client, executionId });
client.emit('ready', client as Client);
allShardsReadyReceived = true;
});
client.login(process.env.DISCORD_BOT_TOKEN);