avocadi-bot/src/actions/dynamicVChannel/dynamicVChannel.service.ts
moriese 56ec6a1ad8
All checks were successful
release-tag / release-image (push) Successful in 56s
added pomodoro function
2025-05-10 00:20:29 +02:00

61 lines
1.7 KiB
TypeScript

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<CacheType>) {
// todo
}
async createVChannel(
newState: VoiceState,
channel: VoiceBasedChannel
): Promise<StageChannel | VoiceChannel> {
//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: <explanation>
channelListeners: Map<any, any>,
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;
}
}