create custom channel discord implementation

This commit is contained in:
mo
2026-03-17 09:13:31 +01:00
parent fc8f90a4bc
commit e4425b23be
7 changed files with 107 additions and 22 deletions

View File

@@ -6,6 +6,7 @@ export interface VoiceChannelsServiceInterface<
createVoiceChannel(name: string): Promise<C>;
cloneVoiceChannel(
user_id: string,
channel: C,
options?: { name?: string; position?: number },
): Promise<C>;

View File

@@ -30,27 +30,29 @@ export class DynamicVoiceChannelsService<
);
}
async createDynamicVoiceChannel(id: string): Promise<C | undefined> {
if (this.validChannelIds.has(id)) {
// Channel is one of the dynamic voice channels, create a new one based on it
async createDynamicVoiceChannel(
user_id: string,
channel_id: string,
): Promise<C | undefined> {
if (!this.validChannelIds.has(channel_id)) return;
// Channel is one of the dynamic voice channels, create a new one based on it
const channel = await this.voiceChannelsService.getVoiceChannelById(id);
const channel =
await this.voiceChannelsService.getVoiceChannelById(channel_id);
if (!channel) return;
if (!channel) return;
const newChannel = await this.voiceChannelsService.cloneVoiceChannel(
channel,
{
name: channel.name,
},
);
const newChannel = await this.voiceChannelsService.cloneVoiceChannel(
user_id,
channel,
{
name: channel.name,
},
);
this.createdChannelIdsSet.add(newChannel.id);
this.createdChannelIdsSet.add(newChannel.id);
return newChannel;
} else {
// Channel is not a dynamic voice channel, do nothing
}
return newChannel;
}
deleteDynamicVoiceChannel(channelId: string): Promise<void> {