From cf8142b86a9992d0c0e6e48a2c4b98a06f5000bf Mon Sep 17 00:00:00 2001 From: Anthony Date: Sat, 27 Jan 2024 19:38:59 +0100 Subject: [PATCH] fix(arabot): deleted channel errors --- src/scheduled-tasks/verifyTimeout.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/scheduled-tasks/verifyTimeout.ts b/src/scheduled-tasks/verifyTimeout.ts index e203338..45d1865 100644 --- a/src/scheduled-tasks/verifyTimeout.ts +++ b/src/scheduled-tasks/verifyTimeout.ts @@ -17,8 +17,8 @@ along with this program. If not, see . */ -import type { VoiceChannel } from 'discord.js'; import { ScheduledTask } from '@sapphire/plugin-scheduled-tasks'; +import { ChannelType } from 'discord.js'; export class VerifyTimeout extends ScheduledTask { public constructor( @@ -32,15 +32,22 @@ export class VerifyTimeout extends ScheduledTask { // Get the guild where the user is in let channel = this.container.client.channels.cache.get( payload.channelId, - ) as VoiceChannel | undefined; + ); if (channel === undefined) { - channel = (await this.container.client.channels.fetch( + const channelFetch = await this.container.client.channels.fetch( payload.channelId, - )) as VoiceChannel | undefined; - if (channel === undefined) { + ).catch(() => null); + if (channelFetch === null) { this.container.logger.error('verifyTimeout: Channel not found!'); return; } + + channel = channelFetch; + } + + if (channel.type !== ChannelType.GuildVoice) { + this.container.logger.error('verifyTimeout: Channel is not a voice channel!'); + return; } if (channel.members.size < 2 && channel.members.has(payload.userId)) {