more logging
This commit is contained in:
@@ -2,19 +2,24 @@ import type { VoiceChannelsServiceInterface } from "@avocadi/bot-core/entities/c
|
||||
import { config } from "config";
|
||||
import { ChannelType, type VoiceChannel } from "discord.js";
|
||||
import client from "lib/client";
|
||||
import { logger } from "lib/common-logger";
|
||||
|
||||
export class VoiceChannelsService
|
||||
implements VoiceChannelsServiceInterface<VoiceChannel>
|
||||
{
|
||||
/***
|
||||
*/
|
||||
async getVoiceChannelById(channelId: string) {
|
||||
const channel = await client.channels.fetch(channelId);
|
||||
|
||||
if (!channel) {
|
||||
throw new Error(`Channel with id ${channelId} not found`);
|
||||
logger.error(`Channel with id ${channelId} not found`);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (channel.type !== ChannelType.GuildVoice) {
|
||||
throw new Error(`Channel with id ${channelId} is not a voice channel`);
|
||||
logger.error(`Channel with id ${channelId} is not a voice channel`);
|
||||
return null;
|
||||
}
|
||||
|
||||
return channel;
|
||||
@@ -43,6 +48,7 @@ export class VoiceChannelsService
|
||||
async deleteVoiceChannel(channelId: string) {
|
||||
const channel = await this.getVoiceChannelById(channelId);
|
||||
|
||||
if (!channel) return;
|
||||
await channel.delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user