Skip to content
Advertisement

How to create a slash command with spacing in the name?

I’ve seen some bots that have space in the name of their slash commands, ex: /admin ban

afk on command along with afk off command

But when I try to implement it, I get an error saying that the name of the slash command does not match a validation regex.

My code:

JavaScript

Error:

JavaScript

Advertisement

Answer

These are called subcommands. They are a good way to sort commands. For example, instead of using setsomething and deletesomething commands, you could use something delete and something set.

You can do this with the options property, and setting the type to SUB_COMMAND

JavaScript

You can get this in the interactionCreate event through .getSubcommand()

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement