From e74bd83ee6204625107b220af9a53b19b0c7685e Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sat, 24 Feb 2024 18:46:46 +0100 Subject: [PATCH] catch channel delete error --- events/channels/voiceStateUpdate.js | 37 +++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/events/channels/voiceStateUpdate.js b/events/channels/voiceStateUpdate.js index 88cfa50..700270a 100644 --- a/events/channels/voiceStateUpdate.js +++ b/events/channels/voiceStateUpdate.js @@ -102,25 +102,26 @@ export const name = Events.VoiceStateUpdate; */ export async function execute(oldState, newState) { const { channel } = newState; - await leftVoiceChat(oldState); - if (!channel) return; - - // Find channel by id, return if not registered for customs - const createCh = await VoiceChannel.findOne({ - where: { - id: channel.id, - create: true - } - }); - if (createCh === null) return; - - // Extract user data - const member = newState.member; - - // Extract channel data - const channels = newState.guild.channels; - let step = 'create'; + let step = 'delete'; try { + await leftVoiceChat(oldState); + if (!channel) return; + + // Find channel by id, return if not registered for customs + const createCh = await VoiceChannel.findOne({ + where: { + id: channel.id, + create: true + } + }); + if (createCh === null) return; + + // Extract user data + const member = newState.member; + + step = 'create'; + // Extract channel data + const channels = newState.guild.channels; const privCh = await getChannel(member, channels, channel); step = 'move to';