add greeting
add locales
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import type { VoiceChannelsServiceInterface } from "@avocadi/bot-core/entities/channels/voice/voice-channels.service";
|
||||
import { config } from "config";
|
||||
import { ChannelType, type VoiceChannel } from "discord.js";
|
||||
import client from "lib/client";
|
||||
|
||||
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`);
|
||||
}
|
||||
|
||||
if (channel.type !== ChannelType.GuildVoice) {
|
||||
throw new Error(`Channel with id ${channelId} is not a voice channel`);
|
||||
}
|
||||
|
||||
return channel;
|
||||
}
|
||||
|
||||
async createVoiceChannel(name: string) {
|
||||
const guild = await client.guilds.fetch(config.guildId);
|
||||
const channel = await guild.channels.create({
|
||||
name,
|
||||
type: ChannelType.GuildVoice,
|
||||
});
|
||||
return channel;
|
||||
}
|
||||
|
||||
async cloneVoiceChannel(
|
||||
channel: VoiceChannel,
|
||||
options?: { name?: string; position?: number },
|
||||
) {
|
||||
const clonedChannel = await channel.clone({
|
||||
name: options?.name,
|
||||
position: options?.position,
|
||||
});
|
||||
return clonedChannel;
|
||||
}
|
||||
|
||||
async deleteVoiceChannel(channelId: string) {
|
||||
const channel = await this.getVoiceChannelById(channelId);
|
||||
|
||||
await channel.delete();
|
||||
}
|
||||
}
|
||||
|
||||
export const voiceChannelsService = new VoiceChannelsService();
|
||||
Reference in New Issue
Block a user