From a7d1f4e6b414684b45e52eeeb5204d25467ee5b6 Mon Sep 17 00:00:00 2001 From: Logan Cusano Date: Sun, 4 Aug 2024 16:01:59 -0400 Subject: [PATCH] Handle join auto complete error and update formatting --- discordBot/commands/join.mjs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/discordBot/commands/join.mjs b/discordBot/commands/join.mjs index 928b3a2..425def4 100644 --- a/discordBot/commands/join.mjs +++ b/discordBot/commands/join.mjs @@ -32,9 +32,14 @@ export async function autocomplete(nodeIo, interaction) { log.DEBUG(focusedValue, choices, filtered); - await interaction.respond( - filtered.map(choice => ({ name: choice.name, value: choice.name })) - ); + try { + await interaction.respond( + filtered.map(choice => ({ name: choice.name, value: choice.name })) + ); + } + catch (e) { + log.WARN("Autocomplete interaction failure", e); + } } /** @@ -71,7 +76,7 @@ export async function execute(nodeIo, interaction) { // If there is one available node, request that node join if (availableNodes.length === 1) { await joinNode(nodeIo, interaction, availableNodes[0].id, system, channelToJoin); - } + } // If there are more than one available, prompt the user for their selected node else { @@ -79,8 +84,8 @@ export async function execute(nodeIo, interaction) { await joinNode(nodeIo, interaction, selectedNode, system, channelToJoin); }); } - } - + } + catch (err) { log.ERROR(err); await interaction.editReply({ content: `An error occurred: ${err.message}`, ephemeral: true });