Error registering a command

I was registering slash commands and I ran to an error: 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/guilds/966987181069598731/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/guilds/966987181069598731/commands', requestBody: { files: undefined, json: [Array] } } } Notes: discord.js v13.8.0 and node.js v16
5 Replies
d.js docs
d.js docs2y ago
• 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.
Pooyan
Pooyan2y ago
What is dictType?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Pooyan
Pooyan2y ago
so what i have to to?
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);
}
})();
}
}
}
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server
More Posts