Mentioning commands that have subcommands.
I have a question regarding how to properly mention commands that have subcommands in a bot.
For example, I have a
/status
command, with the subcommands /status bot
and /status api
.
While I understand that this is a Discord-related issue, I am trying to implement this functionality in my bot. I have structured the commands in an array, with each command being an object.
However, when trying to mention the commands using the following code, it works for all commands except those that contain subcommands:
Could you provide any insights into how I might address this issue?2 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!You would have to see if each command has any subcommands:
* Check the command's
options
* If any option has the type of ApplicationCommandOptionType.Subcommand
, then add a commandString for each subcommand (aka every top-level option of that command)
* Otherwise, just add a commandString for the top-level command
One thing to note: There's a built-in formatter for command mentions called chatInputApplicationCommandMention
which has parameters for the command id, name, and (optional) subcommand name, which might be easier so its just - {mention} - {command.description}