import config from "config"; import client from "lib/client"; import { getRandomInt } from "lib/utils"; import { } from "./dynamicVChannel.components.ts"; import { Client, EmbedBuilder, type Message, type CacheType, type GuildMember, type Interaction, type OmitPartialGroupDMChannel, type VoiceState, type VoiceChannel, type StageChannel, Events, type VoiceBasedChannel, } from "discord.js"; export class DynamicVChannelService { async handleInteraction(interaction: Interaction) { // todo } async createVChannel( newState: VoiceState, channel: VoiceBasedChannel ): Promise { //console.log("createChannel()"); const newVChannel = await channel.clone({ name: `${channel.name.substring(2)}; ${newState.member?.displayName}`, position: 100, }); return newVChannel; } async deleteVChannel( oldState: VoiceState, newState: VoiceState, newChannel: StageChannel | VoiceChannel, // biome-ignore lint/suspicious/noExplicitAny: 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; } }