AlexzanderFlores / WOKCommands

132 stars 61 forks source link

DiscordAPIError: Invalid Form Body on Application Command Create #218

Closed ASPNyan closed 2 years ago

ASPNyan commented 2 years ago

When adding specifically this one command, I get the following error

WOKCommands > Creating guild slash command "embedbuilder"
D:\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:350
      throw new DiscordAPIError(data, res.status, request);
            ^
DiscordAPIError: Invalid Form Body
options[15].name: String value did not match validation regex.
    at RequestHandler.execute (D:\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (D:\Discord Bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async GuildApplicationCommandManager.create (D:\Seb\Discord Bot\node_modules\discord.js\src\managers\ApplicationCommandManager.js:117:18)
    at async SlashCommands.create (D:\Discord Bot\node_modules\wokcommands\dist\SlashCommands.js:130:32)
    at async CommandHandler.registerCommand (D:\Discord Bot\node_modules\wokcommands\dist\CommandHandler.js:247:21)
    at async CommandHandler.setUp (D:\Discord Bot\node_modules\wokcommands\dist\CommandHandler.js:69:17) {
  method: 'post',
  path: '/applications/925211738931073044/guilds/785314186979835924/commands',
  code: 50035,
  httpStatus: 400,
  requestData: {
    json: {
      name: 'embedbuilder',
      description: 'Used to make an Embed. Use "ssp!embed help" for help.',
      type: undefined,
      options: [Array],
      default_permission: undefined
    },
    files: []
  }
}

This only happens on this command and no others, but I have no clue why since there's no visible error or difference (apart from command name, description, etc.)

ASPNyan commented 2 years ago

The code for the mentioned portion is

category: 'testing',
description: 'Used to make an Embed. Use "ssp!embed help" for help.',

slash: true,
testOnly: true,
minArgs: 10,
maxArgs: 16,
expectedArgs: '<title> <subtitle> <ephemeral> <colour-r> <colour-g> <colour-b> <usefield2> <usefield3> <heading1> <text1> <heading2> <text2> <inline2> <heading3> <text3> <inline3> ',
expectedArgsTypes: ['STRING', 'STRING', 'BOOLEAN', 'NUMBER', 'NUMBER', 'NUMBER', 'BOOLEAN', 'BOOLEAN', 'STRING', 'STRING', 'STRING', 'STRING', 'BOOLEAN', 'STRING', 'STRING', 'BOOLEAN'],
ASPNyan commented 2 years ago

The space between <inline3> and the end ' was causing the error. Removing that fixed it