diff --git a/src/bot.ts b/src/bot.ts index 3f57b2d..3c3c7a5 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -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);