Cannot register slash commands discord.js v13
Every time I start registering my application commands, I get this error:
And they are not registered after a few minutes.
Notes: discord.js v13.8.0 node.js v16
<rejected> DiscordAPIError[50035]: Invalid Form Body
0[DICT_TYPE_CONVERT]: Only dictionaries may be used in a DictTyp
<rejected> DiscordAPIError[50035]: Invalid Form Body
0[DICT_TYPE_CONVERT]: Only dictionaries may be used in a DictTyp
2 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.full error:
[antiCrash] :: Unhandled Rejection/Catch
DiscordAPIError[50035]: Invalid Form Body
0[DICT_TYPE_CONVERT]: Only dictionaries may be used in a DictType
at SequentialHandler.runRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:708:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:511:14) {
rawError: {
code: 50035,
errors: { '0': [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'put',
url: 'https://discord.com/api/v9/applications/966666309909770260/commands',
requestBody: { files: undefined, json: [ [Array] ] }
} Promise {
<rejected> DiscordAPIError[50035]: Invalid Form Body
0[DICT_TYPE_CONVERT]: Only dictionaries may be used in a DictType
at SequentialHandler.runRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:708:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:511:14) {
rawError: { code: 50035, errors: [Object], message: 'Invalid Form Body' },
code: 50035,
status: 400,
method: 'put',
url: 'https://discord.com/api/v9/applications/966666309909770260/commands',
requestBody: { files: undefined, json: [Array] }
}
}
[antiCrash] :: Unhandled Rejection/Catch
DiscordAPIError[50035]: Invalid Form Body
0[DICT_TYPE_CONVERT]: Only dictionaries may be used in a DictType
at SequentialHandler.runRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:708:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:511:14) {
rawError: {
code: 50035,
errors: { '0': [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'put',
url: 'https://discord.com/api/v9/applications/966666309909770260/commands',
requestBody: { files: undefined, json: [ [Array] ] }
} Promise {
<rejected> DiscordAPIError[50035]: Invalid Form Body
0[DICT_TYPE_CONVERT]: Only dictionaries may be used in a DictType
at SequentialHandler.runRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:708:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async SequentialHandler.queueRequest (C:\Users\Pooyan\Desktop\PDM Bot\node_modules\@discordjs\rest\dist\index.js:511:14) {
rawError: { code: 50035, errors: [Object], message: 'Invalid Form Body' },
code: 50035,
status: 400,
method: 'put',
url: 'https://discord.com/api/v9/applications/966666309909770260/commands',
requestBody: { files: undefined, json: [Array] }
}
}
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const fs = require('fs');
const clientId = '966666309909770260';
const guildId = '944616601678917632';
module.exports = (client) => {
client.handleCommands = async (slashCommandFolders, path) => {
client.slashCommandArray = [];
for (folder of slashCommandFolders) {
const slashCommandFiles = fs.readdirSync(`${path}/${folder}`).filter(file => file.endsWith('.js'));
for (const file of slashCommandFiles) {
const command = require(`../slashcommands/${folder}/${file}`);
client.slashcommands.set(command.data.name, command)
client.slashCommandArray.push(command.data.toJSON());
}
const rest = new REST({ version: '9' }).setToken(process.env.DISCORD_TOKEN);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [client.slashCommandArray] })
console.log('Started refreshing application (/) commands.');
} catch (error) {
console.error(error);
}
})();
}
}
}
const { REST } = require('@discordjs/rest');
const { Routes } = require('discord-api-types/v9');
const fs = require('fs');
const clientId = '966666309909770260';
const guildId = '944616601678917632';
module.exports = (client) => {
client.handleCommands = async (slashCommandFolders, path) => {
client.slashCommandArray = [];
for (folder of slashCommandFolders) {
const slashCommandFiles = fs.readdirSync(`${path}/${folder}`).filter(file => file.endsWith('.js'));
for (const file of slashCommandFiles) {
const command = require(`../slashcommands/${folder}/${file}`);
client.slashcommands.set(command.data.name, command)
client.slashCommandArray.push(command.data.toJSON());
}
const rest = new REST({ version: '9' }).setToken(process.env.DISCORD_TOKEN);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [client.slashCommandArray] })
console.log('Started refreshing application (/) commands.');
} catch (error) {
console.error(error);
}
})();
}
}
}