more logging

This commit is contained in:
mo
2026-03-01 17:52:06 +01:00
parent 93788b9873
commit f20bdde4e6
3 changed files with 20 additions and 4 deletions

View File

@@ -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();
}
}