From 8fe87c3b4b4b955a96b7a9ec2e38fedaaa937af6 Mon Sep 17 00:00:00 2001 From: Pkmmte Xeleon Date: Sun, 14 May 2023 22:14:14 -0700 Subject: [PATCH] patch: error reply embed field now shows correct subcommand and subcommand group keys Just had to update this with new support for these! --- .changeset/fuzzy-deers-worry.md | 5 +++++ packages/robo/src/core/debug.ts | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .changeset/fuzzy-deers-worry.md diff --git a/.changeset/fuzzy-deers-worry.md b/.changeset/fuzzy-deers-worry.md new file mode 100644 index 000000000..aeeebaf67 --- /dev/null +++ b/.changeset/fuzzy-deers-worry.md @@ -0,0 +1,5 @@ +--- +'@roboplay/robo.js': patch +--- + +patch: error reply embed field now shows correct subcommand and subcommand group keys diff --git a/packages/robo/src/core/debug.ts b/packages/robo/src/core/debug.ts index eb05a1a7a..9d5d6e4e4 100644 --- a/packages/robo/src/core/debug.ts +++ b/packages/robo/src/core/debug.ts @@ -1,3 +1,4 @@ +import { hasProperties } from '../cli/utils/utils.js' import fs from 'node:fs/promises' import { ActionRowBuilder, @@ -50,7 +51,11 @@ export async function printErrorResponse(error: unknown, interaction: unknown, d } // Return if interaction is not a Discord command interaction or a message directed at the bot - if (!(interaction instanceof CommandInteraction) && !(interaction instanceof Message) && !(interaction instanceof ButtonInteraction)) { + if ( + !(interaction instanceof CommandInteraction) && + !(interaction instanceof Message) && + !(interaction instanceof ButtonInteraction) + ) { return } @@ -185,9 +190,25 @@ async function formatError(options: FormatErrorOptions): Promise string }>(interaction.options, ['getSubcommandGroup'])) { + try { + commandKeys.push(interaction.options.getSubcommandGroup()) + } catch { + // Ignore + } + } + if (hasProperties<{ getSubcommand: () => string }>(interaction.options, ['getSubcommand'])) { + try { + commandKeys.push(interaction.options.getSubcommand()) + } catch { + // Ignore + } + } + fields.push({ name: 'Command', - value: '`/' + interaction.commandName + '`' + value: '`/' + commandKeys.filter(Boolean).join(' ') + '`' }) } if (details) {