-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: crash relating to leaving guild while session is active
- Loading branch information
Showing
1 changed file
with
11 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
import type { WardenClient, WardenPlayer } from '#src/lib/util/common.d.js'; | ||
import { logger } from '#src/lib/util/common.js'; | ||
import type { Guild } from 'discord.js'; | ||
|
||
export default { | ||
name: 'guildDelete', | ||
once: false, | ||
execute(guild: Guild): void { | ||
async execute(guild: Guild & { client: WardenClient }): Promise<void> { | ||
logger.info({ | ||
message: `[G ${guild.id}] Left guild ${guild.name}`, | ||
label: 'Discord', | ||
}); | ||
const player = guild.client.tts.players.get(guild.id) as WardenPlayer; | ||
if (player) { | ||
logger.info({ | ||
message: `[G ${guild.id}] Cleaning up`, | ||
label: 'Warden', | ||
}); | ||
player.channelId = null; | ||
return player.handler.disconnect(); | ||
} | ||
}, | ||
}; |