Discord API error [50035] : invalid form body

heres the code of slash command
// Slash
const slashcommands = [];
readdirSync("./src/commands/slash").forEach(async (file) => {
const command = require(`./src/commands/slash/${file}`);
slashcommands.push(JSON.stringify(command.data))
client.slashcommands.set(command.data.name, command);
});
// Slash
const slashcommands = [];
readdirSync("./src/commands/slash").forEach(async (file) => {
const command = require(`./src/commands/slash/${file}`);
slashcommands.push(JSON.stringify(command.data))
client.slashcommands.set(command.data.name, command);
});
code of one of my slash command
const { SlashCommandBuilder } = require("@discordjs/builders");
const { EmbedBuilder } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Pong!"),
run: async (client, interaction) => {
const startTime = Date.now();
const reply = await interaction.reply({ content: "Pinging...", ephemeral: true });

const endTime = Date.now();
const ping = endTime - startTime;

const embed = new EmbedBuilder()
.setTitle("Pong! 🏓")
.setDescription(`Bot latency: ${ping}ms\nAPI latency: ${client.ws.ping}ms`)
.setColor("#00ff00");

reply.edit({ content: "\u200B", embeds: [embed], ephemeral: true });
},
};
const { SlashCommandBuilder } = require("@discordjs/builders");
const { EmbedBuilder } = require("discord.js");

module.exports = {
data: new SlashCommandBuilder()
.setName("ping")
.setDescription("Pong!"),
run: async (client, interaction) => {
const startTime = Date.now();
const reply = await interaction.reply({ content: "Pinging...", ephemeral: true });

const endTime = Date.now();
const ping = endTime - startTime;

const embed = new EmbedBuilder()
.setTitle("Pong! 🏓")
.setDescription(`Bot latency: ${ping}ms\nAPI latency: ${client.ws.ping}ms`)
.setColor("#00ff00");

reply.edit({ content: "\u200B", embeds: [embed], ephemeral: true });
},
};
No description
No description
13 Replies
d.js toolkit
d.js toolkit9mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Sav
SavOP9mo ago
"discord.js": "^14.13.0",
Sav
SavOP9mo ago
Sav
SavOP9mo ago
like this slashcommands.push(command.data.toJSON()); ? @Qjuh but uh when i use that it says cannot read properties of undefined reading 'toJSON' thats why i used stringify bc someone said to use that and i have to reinvite the bot everytime when i add a new slash command bc of that error ohhh so one of my command is doing that?? welp now i have to find it i have so many commands
Amgelo
Amgelo9mo ago
you could log the name of the file before trying to do something with it so you know which one is failing
Sav
SavOP9mo ago
how can i do that
Amgelo
Amgelo9mo ago
logging it? with console.log
Sav
SavOP9mo ago
oh yea
Sav
SavOP9mo ago
tysm @Qjuh and @Amgelo i fixed it
No description
Sav
SavOP9mo ago
there was 3 random.js files with nothing inside uh oh one problem i still have to reinvite the bot for it to show new slash commands.. no errors or anything.. @Amgelo
Amgelo
Amgelo9mo ago
are you sure that's not just your client cache? you could try restarting your client ctrl + r also, not related to your issue but that's a ton of intents I'm almost certain you don't need all of them
Sav
SavOP9mo ago
yeah ik but i just keep it there
Amgelo
Amgelo9mo ago
it's recommended for you to only keep the ones you need that's the whole point of intents after all else they wouldn't be a thing
Want results from more Discord servers?
Add your server