able to duplicate channel with only joining
All checks were successful
release-tag / release-image (push) Successful in 24s
All checks were successful
release-tag / release-image (push) Successful in 24s
This commit is contained in:
52
src/actions/dynamicChannel/dynamicChannel.service.ts
Normal file
52
src/actions/dynamicChannel/dynamicChannel.service.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user