able to duplicate channel with only joining
All checks were successful
release-tag / release-image (push) Successful in 24s

This commit is contained in:
moriese
2025-01-13 01:47:27 +01:00
parent 6193865220
commit 3f7864be1b
6 changed files with 149 additions and 33 deletions

View File

@@ -0,0 +1,52 @@
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<CacheType>) {
// todo
}
async createChannel(oldState: VoiceState, newState: VoiceState, channel: VoiceBasedChannel): Promise<StageChannel | VoiceChannel> {
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<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;
}
}