From 2e521aadd75bf8383400759c196413d03d926ef5 Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Fri, 20 Nov 2020 02:13:37 +0100 Subject: [PATCH] Move verbose errors --- .../src/plugins/Utility/commands/VcmoveCmd.ts | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/backend/src/plugins/Utility/commands/VcmoveCmd.ts b/backend/src/plugins/Utility/commands/VcmoveCmd.ts index eb168dd8..1fddcdad 100644 --- a/backend/src/plugins/Utility/commands/VcmoveCmd.ts +++ b/backend/src/plugins/Utility/commands/VcmoveCmd.ts @@ -155,23 +155,34 @@ export const VcmoveAllCmd = utilityCmd({ return; } - let moveAmt = 0; + // Cant leave null, otherwise we get an assignment error in the catch + let currMember = msg.member; + const moveAmt = args.oldChannel.voiceMembers.size; try { for (const memberWithId of args.oldChannel.voiceMembers) { - moveAmt++; - memberWithId[1].edit({ + currMember = memberWithId[1]; + + currMember.edit({ channelID: channel.id, }); pluginData.state.logs.log(LogType.VOICE_CHANNEL_FORCE_MOVE, { mod: stripObjectToScalars(msg.author), - member: stripObjectToScalars(memberWithId[1], ["user", "roles"]), + member: stripObjectToScalars(currMember, ["user", "roles"]), oldChannel: stripObjectToScalars(args.oldChannel), newChannel: stripObjectToScalars(channel), }); } } catch (e) { - msg.channel.createMessage(errorMessage(`Failed to move the ${moveAmt} member we tried to move.`)); + if (msg.member.id === currMember.id) { + sendErrorMessage(pluginData, msg.channel, "Unknown error when trying to move members"); + return; + } + sendErrorMessage( + pluginData, + msg.channel, + `Failed to move ${currMember.username}#${currMember.discriminator} (${currMember.id})`, + ); return; }