fix(arabot): deleted channel errors

This commit is contained in:
Anthony 2024-01-27 19:38:59 +01:00
parent 502d5c5cdf
commit cf8142b86a

View File

@ -17,8 +17,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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)) {