update custom channel discord
This commit is contained in:
@@ -49,7 +49,6 @@ export class VoiceChannelsService
|
||||
},
|
||||
],
|
||||
});
|
||||
logger.info("DONE");
|
||||
return clonedChannel;
|
||||
}
|
||||
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user