Reputation: 251
I am trying to create a /config <subcommand>
system for my bot, but it gives me an error with the slash command body.
Here is the current body I have for the command
name: 'config',
description: "The config system for the bot",
userPermissions: ['MANAGE_GUILD'],
options: [
{
name: 'prefix',
description: "Set a different prefifor the server",
type: "SUB_COMMAND",
options: [
{name: "new-prefix", description: "The new prefix that you want to set", type: "STRING", required: true}
]
}
]
The error is
DiscordAPIError[50035]: Invalid Form Body
0.options[0].options[0].type[NUMBER_TYPE_COERCE]: Value "STRING" is not int.
0.options[0].type[NUMBER_TYPE_COERCE]: Value "SUB_COMMAND" is not int.
I have never encountered this error before
Upvotes: 1
Views: 1869
Reputation: 21
As you are using raw json to register your commands, the type of your options must be an integer, instead of a string.
Why? Because Discord API accepts integers, not strings.
Each type has an associated id integer as documented here, which is what you have to use instead of strings.
In your case, type: "SUB_COMMAND"
should be type: 1
Why options types are documented as strings in the discord.js docs? Because they made it strings to improve code readability. The lib does "convert" these strings to int before requesting the API. But you are using raw json in this case.
You can check for other application commands options type in Discord Developer Documentation
Upvotes: 2