From cb1662cefb4c04b90db96126a86e4e756b1ec955 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Thu, 8 Feb 2024 20:13:12 +0100 Subject: [PATCH] bugfix: only delete registered custom channels --- events/channels/voiceStateUpdate.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/events/channels/voiceStateUpdate.js b/events/channels/voiceStateUpdate.js index 209a281..ae449eb 100644 --- a/events/channels/voiceStateUpdate.js +++ b/events/channels/voiceStateUpdate.js @@ -63,6 +63,15 @@ const leftVoiceChat = async (state) => { const members = Array.from(channel.members); if (members.length > 0) return; + // Find channel by id, return if not registered as custom + const custom = await VoiceChannel.findOne({ + where: { + id: channel.id, + create: false + } + }); + if (custom === null) return; + // Delete channel from guild await channel.guild.channels.delete(channel.id); console.info(`[INFO] Custom VC with ID '${channel.id}' was empty and got deleted.`); @@ -73,6 +82,18 @@ export async function execute(oldState, newState) { if (!newState.channel) return await leftVoiceChat(oldState); + console.log( + Array.from( + newState + .channel + .permissionOverwrites + .cache + .values() + ).forEach(overwrite => + console.log(overwrite.allow.toArray()) + ) + ); + // Find channel by id, return if not registered for customs const createCh = await VoiceChannel.findOne({ where: {