How to solve invalid form body
DiscordAPIError[50035]: Invalid Form Body
application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
at SequentialHandler.runRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:667:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:464:14)
at async REST.request (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:910:22)
at async E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\deploy-commands.js:24:16 {
requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] },
rawError: {
code: 50035,
errors: { application_id: [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/undefined/commands'
}
[I] 2023/01/10 14:40:44 All Windows descendant process exited.
[I] 2023/01/10 14:40:44 Master exiting
DiscordAPIError[50035]: Invalid Form Body
application_id[NUMBER_TYPE_COERCE]: Value "undefined" is not snowflake.
at SequentialHandler.runRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:667:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:464:14)
at async REST.request (E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\node_modules\@discordjs\rest\dist\index.js:910:22)
at async E:\htcqq\Desktop\FTVTC\网站\Federal-Transport\Federal-Transport-Bot\deploy-commands.js:24:16 {
requestBody: { files: undefined, json: [ [Object], [Object], [Object] ] },
rawError: {
code: 50035,
errors: { application_id: [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/undefined/commands'
}
[I] 2023/01/10 14:40:44 All Windows descendant process exited.
[I] 2023/01/10 14:40:44 Master exiting
11 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Show your code
the deploy-commands.js ?
Yes
const { REST, Routes } = require('discord.js');
const { clientId, token } = require('./config.json');
const fs = require('node:fs');
const commands = [];
// Grab all the command files from the commands directory you created earlier
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}
// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
const { REST, Routes } = require('discord.js');
const { clientId, token } = require('./config.json');
const fs = require('node:fs');
const commands = [];
// Grab all the command files from the commands directory you created earlier
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
// Grab the SlashCommandBuilder#toJSON() output of each command's data for deployment
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
commands.push(command.data.toJSON());
}
// Construct and prepare an instance of the REST module
const rest = new REST({ version: '10' }).setToken(token);
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
Do you have clientId in your config file?
yeah
Show it
Remove your token first
{
"token": "***",
"clinetId":"1061655579195609158",
"guildId":"1049362823412727838"
}
{
"token": "***",
"clinetId":"1061655579195609158",
"guildId":"1049362823412727838"
}
You don't have clientId, but clinetId
oh
thx