mirror of
https://github.com/darksaid98/cadence-discord-bot.git
synced 2026-12-04 14:38:49 +00:00
fix: possibly solve duplicate event 'interactionCreate' listener bug
This commit is contained in:
1 parent
2d7ffc1a3f
commit
2d08a9aa85
1 file changed
+9
@@ -26,11 +26,20 @@ const logger: Logger = loggerModule.child({
|
|||||||
const client: ExtendedClient = await createClient({ executionId });
|
const client: ExtendedClient = await createClient({ executionId });
|
||||||
const player: Player = await createPlayer({ client, executionId });
|
const player: Player = await createPlayer({ client, executionId });
|
||||||
|
|
||||||
|
let allShardsReadyReceived: boolean = false;
|
||||||
|
|
||||||
client.on('allShardsReady', async () => {
|
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;
|
client.registerClientInteractions = registerClientInteractions;
|
||||||
await registerEventListeners({ client, player, executionId });
|
await registerEventListeners({ client, player, executionId });
|
||||||
await registerClientInteractions({ client, executionId });
|
await registerClientInteractions({ client, executionId });
|
||||||
client.emit('ready', client as Client);
|
client.emit('ready', client as Client);
|
||||||
|
allShardsReadyReceived = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
client.login(process.env.DISCORD_BOT_TOKEN);
|
client.login(process.env.DISCORD_BOT_TOKEN);
|
||||||
|
|||||||
Reference in new issue
Block a user