1

I just downloaded discord.js v14 (not the latest release) and I'm getting the error. I can't find what I did wrong but it was working in v13.1.0.

DiscordAPIError[50035]: Invalid Form Body
0.type[NUMBER_TYPE_COERCE]: Value "CHAT_INPUT" is not int.
3.options[0].type[NUMBER_TYPE_COERCE]: Value "USER" is not int.
3.options[1].type[NUMBER_TYPE_COERCE]: Value "STRING" is not int.
4.options[0].type[NUMBER_TYPE_COERCE]: Value "USER" is not int.
4.options[1].type[NUMBER_TYPE_COERCE]: Value "STRING" is not int.
    at SequentialHandler.runRequest (H:\Projects\Discord\Handler\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:293:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.queueRequest (H:\Projects\Discord\Handler\node_modules\@discordjs\rest\dist\lib\handlers\SequentialHandler.cjs:99:14)
    at async REST.request (H:\Projects\Discord\Handler\node_modules\@discordjs\rest\dist\lib\REST.cjs:52:22)
    at async GuildApplicationCommandManager.set (H:\Projects\Discord\Handler\node_modules\discord.js\src\managers\ApplicationCommandManager.js:173:18)
    at async H:\Projects\Discord\Handler\handler\index.js:47:13 {

If you need to know, here's where the error points to:

await guild.commands.set(slashcmds);
05_4
  • 27
  • 3

1 Answers1

0

I've found out what I did wrong. To people reading this in the future, here's the answer:

Discord has changed from strings to enums, here's what they changed in my case ("+" means added, "-" means deprecated)

+ const { ApplicationCommandType, ApplicationCommandOptionType } = require('discord.js');

const command = {
  name: 'ping',
- type: 'CHAT_INPUT',
+ type: ApplicationCommandType.ChatInput,
  options: [{
    name: 'option',
    description: 'A sample option',
-   type: 'STRING',
+   type: ApplicationCommandOptionType.String,
  }],
};
05_4
  • 27
  • 3
  • 1
    You might also want to check the rest of the upgrade guide. https://discordjs.guide/additional-info/changes-in-v14.html#before-you-start – AKX Aug 31 '22 at 07:02