update custom channel discord

This commit is contained in:
mo
2026-03-17 10:32:22 +01:00
parent e4425b23be
commit 13fd3d5812
5 changed files with 30 additions and 7 deletions

View File

@@ -49,7 +49,6 @@ export class VoiceChannelsService
},
],
});
logger.info("DONE");
return clonedChannel;
}

View File

@@ -25,7 +25,7 @@ export const handleDynamicVoiceChannelCreation = async (
// New channel is created if user joined one of the specific channels (e.g. "Join to Create") or switched to one of them
const newChannel =
await dynamicVoiceChannelService.createDynamicVoiceChannel(
member.id,
{ name: member.displayName, id: member.id },
channel.id,
);
logger.debug(`Channel found for VoiceStateUpdate event: ${channel.name}`);

View File

@@ -6,14 +6,22 @@ export const handleDynamicVoiceChannelDeletion = async (
oldState: VoiceState,
newState: VoiceState,
) => {
if (!(oldState || newState)) return;
const userSwitchedChannel = oldState.channelId !== newState.channelId;
const userLeftChannel = !oldState.channelId && newState.channelId;
// Check if user left a channel that was created by the bot and delete it if it's empty
if (oldState.channelId && !newState.channelId) {
if (userSwitchedChannel || userLeftChannel) {
const channelId = oldState.channelId;
if (!channelId) return;
if (dynamicVoiceChannelService.createdChannelIdsSet.has(channelId)) {
const channel = await voiceChannelsService.getVoiceChannelById(channelId);
if (!channel) return;
if (channel.members.size === 0) {
await dynamicVoiceChannelService.deleteDynamicVoiceChannel(channelId);
}