From 6d21838f7f7ae8731a9ada1615639a74b4d7f677 Mon Sep 17 00:00:00 2001 From: Isaac Date: Thu, 7 Oct 2021 11:10:06 +0100 Subject: [PATCH] fix: tag command errors --- src/commands/tag.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/commands/tag.js b/src/commands/tag.js index eb93f80..7bbf00b 100644 --- a/src/commands/tag.js +++ b/src/commands/tag.js @@ -23,7 +23,6 @@ module.exports = class TagCommand extends Command { required: true, type: Command.option_types.STRING })), - required: true, type: Command.option_types.SUB_COMMAND })); }, @@ -39,11 +38,10 @@ module.exports = class TagCommand extends Command { const settings = await this.client.utils.getSettings(interaction.guild.id); const i18n = this.client.i18n.getLocale(settings.locale); - const tag_name = interaction.options.getSubcommand(); - const tag = settings.tags[tag_name]; - const args = interaction.options.data[0]?.options; - - if (tag) { + try { + const tag_name = interaction.options.getSubcommand(); + const tag = settings.tags[tag_name]; + const args = interaction.options.data[0]?.options; const text = tag.replace(/(? { const arg = args.find(arg => arg.name === $1); return arg ? arg.value : $; @@ -56,7 +54,7 @@ module.exports = class TagCommand extends Command { ], ephemeral: false }); - } else { + } catch { const list = Object.keys(settings.tags).map(t => `❯ **\`${t}\`**`); return await interaction.reply({ embeds: [ @@ -69,6 +67,5 @@ module.exports = class TagCommand extends Command { ephemeral: true }); } - } };