diff --git a/src/clients/discord/discord.voice.service.ts b/src/clients/discord/discord.voice.service.ts index 25a070a..bb51bf0 100644 --- a/src/clients/discord/discord.voice.service.ts +++ b/src/clients/discord/discord.voice.service.ts @@ -129,6 +129,12 @@ export class DiscordVoiceService implements OnModuleDestroy { voiceChannelId, )) as VoiceChannel | undefined; if (voiceChannel === undefined) { + if (!this.autoLeaveIntervalId) { + this.logger.error( + 'Unable to cancel interval because interval id is not defined', + ); + return; + } clearInterval(this.autoLeaveIntervalId); return; } @@ -138,6 +144,10 @@ export class DiscordVoiceService implements OnModuleDestroy { if (voiceChannelMembersExpectBots.size > 0) return; + if (!this.autoLeaveIntervalId) { + return; + } + try { this.stop(true); this.disconnect();