#DiscordAPIError 50035 Invalid Form Body
1 messages · Page 1 of 1 (latest)
Application Commands must have unique names
You have 2 or more commands with the same name
Can I see it?
Are you including some other command as well
Because if the error says so then you must be using 2 commands with the same name
but im not?
which is whats confusing
could be my command handler
although this command handler is working with my other bot
Send the handler code
const { REST } = require("@discordjs/rest");
const { Routes } = require('discord-api-types/v9');
const fs = require('fs');
const config = require('../config.json')
const clientId = '939900690153742346';
module.exports = (client) => {
client.handleCommands = async (commandFolders, path) => {
client.commandArray = [];
for (folder of commandFolders) {
const commandFiles = fs.readdirSync(${path}).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(../slash/${file});
client.commands.set(command.data.name, command);
client.commandArray.push(command.data.toJSON());
}
}
const rest = new REST({
version: '9'
}).setToken(config.token);
(async () => {
try {
console.log('Started refreshing application (/) commands.');
await rest.put(
Routes.applicationCommands(clientId), {
body: client.commandArray
},
);
console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
};
};
module.exports = (client) => {
client.handleEvents = async (eventFiles, path) => {
for (const file of eventFiles) {
const event = require(../events/${file});
if (event.once) {
client.once(event.name, (...args) => event.execute(...args, client));
} else {
client.on(event.name, (...args) => event.execute(...args, client));
}
}
};
}
const { Client, ActionRowBuilder,ButtonStyle, ActivityType, GatewayIntentBits, EmbedBuilder, StringSelectMenuBuilder,PermissionsBitField, Permissions, MessageManager, Embed, Collection, Events, ModalBuilder, TextInputBuilder, TextInputStyle, ButtonBuilder, SelectMenuOptionBuilder } = require(discord.js);
const fs = require('fs');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
const config = require('./config.json')
client.commands = new Collection();
const functions = fs.readdirSync("./functions").filter(file => file.endsWith(".js"));
const eventFiles = fs.readdirSync("./events").filter(file => file.endsWith(".js"));
const commandFolders = fs.readdirSync("./slash");
(async () => {
for (file of functions) {
require(./functions/${file})(client);
}
client.handleEvents(eventFiles, "./events");
client.handleCommands(commandFolders, "./slash");
client.login(config.token)
})();
client.on(Events.ClientReady, async () => {
const activities = [`BluePod ${client.guilds.cache.size} Servers`, `https://bluepod.tk`];
setInterval(() => {
let activity = activities[Math.floor(Math.random() * activities.length)];
client.user.setActivity(activity, { type: ActivityType.Watching });
}, 2000);
}) // dont touch
module.exports = {
name: 'ready',
once: true,
async execute(client) {
console.log('Ready!');
async function pickPresence () {
const option = Math.floor(Math.random() * statusArray.length);
try {
await client.user.setPresence({
activities: [
{
name: statusArray[option].content,
type: statusArray[option].type,
},
],
status: statusArray[option].status
})
} catch (error) {
console.error(error);
}
}
},
};
const { Interaction } = require("discord.js");
module.exports = {
name: 'interactionCreate',
async execute(interaction, client) {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return
try{
await command.execute(interaction, client);
} catch (error) {
console.log(error);
await interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true
});
}
},
};
there
all the code
You should use v10
v10 is the latest version although not related to the error
Were you able to fix it?
no
i replaced v9 with v10
but
it didnt change it
still: Started refreshing application (/) commands.
DiscordAPIError[50035]: Invalid Form Body
2[APPLICATION_COMMANDS_DUPLICATE_NAME]: Application command names must be unique
at SequentialHandler.runRequest (C:\Users\xbox3\Downloads\node_modules@discordjs\rest\dist\index.js:933:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (C:\Users\xbox3\Downloads\node_modules@discordjs\rest\dist\index.js:712:14)
at async REST.request (C:\Users\xbox3\Downloads\node_modules@discordjs\rest\dist\index.js:1321:22)
at async C:\Users\xbox3\Downloads\BluePodV2.0\functions\handelCommands.js:29:17 {
rawError: {
code: 50035,
errors: { '2': [Object] },
message: 'Invalid Form Body'
},
code: 50035,
status: 400,
method: 'PUT',
url: 'https://discord.com/api/v10/applications/939900690153742346/commands',
requestBody: {
files: undefined,
json: [ [Object], [Object], [Object], [Object] ]
}
}
you have duplicating command names. there's really not much more we can say besides making sure your command names are different
u saw that there different
i sent ss
discord says otherwise
BUT I SENT SCREENSHOTS
chill out
SO U CAN SEE THAT THEY DIFFERENT
Then it must be discord's fault
no
im not in the mood for this bs
We are not too
neither am i with that attitude
good luck
hows that ungrateful
thats too far...completely unnecessary
i used in my old bot
So this might take some time
discord.js v13 bot
i just wanted to upgrade to more stable version
v13 is stable
and keep it updated
ik
but
i want a new version
i want to stay updated
so im recode bot
Well can I see the file structure
yea
i tried adding community and it doesnt error but it still doesnt register commands
so we kinda stuck
in between a barrier
but it doesnt register commands
What was the issue?