From 984aaecc532a0bb53ee5164fa73076acd567cadf Mon Sep 17 00:00:00 2001 From: Nathaniel Mason Date: Fri, 22 Apr 2022 06:22:02 +0100 Subject: [PATCH] Filter lists down to only used inputs --- commands/choose.js | 3 ++- commands/reload.js | 4 ++-- start.js | 34 +++++++++++++++++----------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/commands/choose.js b/commands/choose.js index d295970..6e71126 100644 --- a/commands/choose.js +++ b/commands/choose.js @@ -19,7 +19,8 @@ module.exports = { }, async parseInteraction (client, config, interaction) { - await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)))); + console.log([...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str)); + await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str))); }, handle (client, config, user, options) { diff --git a/commands/reload.js b/commands/reload.js index d3f9487..8ea1693 100644 --- a/commands/reload.js +++ b/commands/reload.js @@ -16,7 +16,7 @@ module.exports = { }, async parseInteraction (client, config, interaction) { - await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)))); + await interaction.reply(this.handle(client, config, interaction.user, [...Array(10).keys()].map(i => interaction.options.getString(`option${i + 1}`)).filter(str => str))); }, handle (client, config, user, args) { @@ -25,7 +25,7 @@ module.exports = { let returnMessage = ''; args.forEach(async (arg) => { - const commandName = arg.toLowerCase(); + const commandName = arg?.toLowerCase(); const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName)); diff --git a/start.js b/start.js index 76a423a..f83cf76 100755 --- a/start.js +++ b/start.js @@ -32,27 +32,27 @@ client.generateErrorMessage = (errorMsg, avatarURL) => ({ client.on('error', (e) => console.log(`[ERROR] ${e}`)); client.on('warn', (e) => (`[WARN] ${e}`)); client.once('ready', async () => { - const commands = config.sandbox ? client.guilds.cache.get(config.sandboxGuild)?.commands : client.application.commands; + // const commands = config.sandbox ? client.guilds.cache.get(config.sandboxGuild)?.commands : client.application.commands; // Be careful about running the code below, there's a 200-per-day limit on creating slash commands - if (config.sandbox) { - console.log('deleting previous commands from sandbox'); - const localCommands = await commands.fetch(); - localCommands.forEach(async x => { - await commands.delete(x); - }); + // if (config.sandbox) { + // console.log('deleting previous commands from sandbox'); + // const localCommands = await commands.fetch(); + // localCommands.forEach(async x => { + // await commands.delete(x); + // }); - console.log('deleting global commands'); - const globalCommands = await client.application.commands.fetch(); - globalCommands.forEach(async x => { - await client.application.commands.delete(x); - }); - } + // console.log('deleting global commands'); + // const globalCommands = await client.application.commands.fetch(); + // globalCommands.forEach(async x => { + // await client.application.commands.delete(x); + // }); + // } - client.commands.forEach(async command => { - await commands.create(command); - console.log(command); - }); + // client.commands.forEach(async command => { + // await commands.create(command); + // console.log(command); + // }); console.clear(); console.log(' ___ _ __ ');