I've seen some bots that have space in the name of their slash mands, ex: /admin ban
But when I try to implement it, I get an error saying that the name of the slash mand does not match a validation regex.
My code:
guildmands.create({
name: 'foo bar',
description: 'random description here'
});
Error:
DiscordAPIError: Invalid Form Body
name: String value did not match validation regex.
I've seen some bots that have space in the name of their slash mands, ex: /admin ban
But when I try to implement it, I get an error saying that the name of the slash mand does not match a validation regex.
My code:
guild.mands.create({
name: 'foo bar',
description: 'random description here'
});
Error:
DiscordAPIError: Invalid Form Body
name: String value did not match validation regex.
These are called submands. They are a good way to sort mands. For example, instead of using setsomething
and deletesomething
mands, you could use something delete
and something set
.
You can do this with the options
property, and setting the type to SUB_COMMAND
guild.mands.create({
name: "foo",
description: "random description here",
options: [
{
type: "SUB_COMMAND",
name: "bar",
description: "some description"
}
]
})
You can get this in the interactionCreate
event through .getSubmand()
const submand = interaction.options.getSubmand() // "bar"