import config from "config"; import client from "lib/client"; import { getRandomInt } from "lib/utils"; import { } from "./dynamicChannel.components.ts"; import { Client, EmbedBuilder, type Message, type CacheType, type GuildMember, type Interaction, type OmitPartialGroupDMChannel, VoiceState, VoiceChannel, StageChannel, Events, type VoiceBasedChannel, } from "discord.js"; export class DynamicChannelService { async handleInteraction(interaction: Interaction) { // todo } async createChannel(oldState: VoiceState, newState: VoiceState, channel: VoiceBasedChannel): Promise { console.log("createChannel()"); const newChannel = await channel.clone({ name: channel.name + " " + newState.member?.displayName, position: channel.position }); return newChannel; } async deleteChannel(oldState: VoiceState, newState: VoiceState, newChannel: StageChannel | VoiceChannel, channelListeners: Map, channelListener: (oldState: VoiceState, newState: VoiceState) => void) { console.log("deleteChannel()"); if (oldState.channelId === newChannel.id || newState.channelId === newChannel.id) { if (newChannel.members.size === 0) { newChannel.delete() .catch(console.error); client.removeListener(Events.VoiceStateUpdate, channelListener); channelListeners.delete(newChannel.id); } } return channelListeners; } }