From cff1f5788cf88984db64ae4a4e24df943fcf4c23 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 30 Jul 2026 15:20:30 +0000 Subject: [PATCH] Guard guildDelete broadcast against ShardingInProcess crash guildDelete.run() called this.client.shard.broadcastEval() and setActivity() with no error handling. When a guild-leave event fires on a ready shard during the fleet spawn window, both throw ShardingInProcess; with no unhandledRejection handler the shard process dies and every user on it temporarily loses the bot. Wrap the log broadcast and setActivity in a try/catch that logs and continues, mirroring the analytics block below. Also correct the copy-pasted [GuildCreate] log tag to [GuildDelete] on the touched line. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_015fmAjXRLY4gNz7LttcaiGh --- src/events/guildDelete.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/events/guildDelete.js b/src/events/guildDelete.js index f584d10..42830ff 100644 --- a/src/events/guildDelete.js +++ b/src/events/guildDelete.js @@ -36,10 +36,16 @@ class GuildDelete extends Event { } } - await this.client.shard.broadcastEval(sendLoggedMessage, { context: { guild, emojis, iconURL: guild.iconURL(), ownerUsername: owner?.tag } }); + // Fired on a ready shard during the spawn window, broadcastEval/setActivity + // throw ShardingInProcess; swallow it so a leave event can't crash the shard. + try { + await this.client.shard.broadcastEval(sendLoggedMessage, { context: { guild, emojis, iconURL: guild.iconURL(), ownerUsername: owner?.tag } }); - log.info(`[GuildCreate] uwu bot LEFT a server: ${guild.name}`); - await this.client.setActivity(); + log.info(`[GuildDelete] uwu bot LEFT a server: ${guild.name}`); + await this.client.setActivity(); + } catch (error) { + log.error(`[GuildDelete] Error broadcasting leave event: ${error}`); + } // Save to analytics. try {