From 13550412388f2f45ce4facaa7114a34793016651 Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Mon, 26 Jun 2023 09:43:57 -0600 Subject: [PATCH] Fix duplicates in next user function causing it to think an extension is free when it isnt --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a3e8487..a148288 100644 --- a/index.js +++ b/index.js @@ -169,6 +169,16 @@ const findNextExtension = () => { exts.push(Number(ext.user.extension)); }); exts.sort((a, b) => a - b); + // Find duplicate extensions and remove all but the first + for (var i = 0; i < exts.length; i++) { + if (exts[i] == exts[i + 1]) { + exts.splice(i, 1); + i--; + } + } + + + // Start should be the lowest extension. If none exists use config value // Await if statement var start = 0; @@ -738,7 +748,7 @@ dcClient.on('interactionCreate', async interaction => { interaction.member.roles.remove(role); } }).catch((error) => { - interaction.reply(`Error deleting extension: ${error}`); + interaction.editReply(`Error deleting extension: ${error}`); }); } }).catch((error) => {