Code not working

const { REST, Routes } = require('discord.js');
const BotID = "1172706429157773443";
const token = process.env.Fortune_Haven;
const ServerID = "1191941239692595321";

const rest = new REST({ version: '9' }).setToken(token);

const commands = [
{
name: "dropunique",
description: "Drops an item from the shop",
options: [
{
type: 3,
name: "assetId",
description: "Input the assetId of the item you want to spawn",
required: true,
},
],
},
];

const slashRegister = async () => {
try {
console.log("Started refreshing application (/) commands.");

await rest.put(
Routes.applicationGuildCommands(BotID, ServerID),
{
body: commands,
}
);

console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}
};

slashRegister();
const { REST, Routes } = require('discord.js');
const BotID = "1172706429157773443";
const token = process.env.Fortune_Haven;
const ServerID = "1191941239692595321";

const rest = new REST({ version: '9' }).setToken(token);

const commands = [
{
name: "dropunique",
description: "Drops an item from the shop",
options: [
{
type: 3,
name: "assetId",
description: "Input the assetId of the item you want to spawn",
required: true,
},
],
},
];

const slashRegister = async () => {
try {
console.log("Started refreshing application (/) commands.");

await rest.put(
Routes.applicationGuildCommands(BotID, ServerID),
{
body: commands,
}
);

console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}
};

slashRegister();
11 Replies
d.js toolkit
d.js toolkit5mo 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! - Marked as resolved by OP
Anthonyo
Anthonyo5mo ago
Started refreshing application (/) commands. DiscordAPIError[50035]: Invalid Form Body 0.options[0].name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid at handleErrors (/home/runner/Fortune-Haven/node_modules/@discordjs/rest/dist/index.js:722:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async SequentialHandler.runRequest (/home/runner/Fortune-Haven/node_modules/@discordjs/rest/dist/index.js:1120:23) at async SequentialHandler.queueRequest (/home/runner/Fortune-Haven/node_modules/@discordjs/rest/dist/index.js:953:14) at async _REST.request (/home/runner/Fortune-Haven/node_modules/@discordjs/rest/dist/index.js:1266:22) at async slashRegister (/home/runner/Fortune-Haven/Slash-Commands.js:27:5) { requestBody: { files: undefined, json: [ [Object] ] }, rawError: { message: 'Invalid Form Body', code: 50035, errors: { '0': [Object] } }, code: 50035, status: 400, method: 'PUT', url: 'https://discord.com/api/v9/applications/1172706429157773443/guilds/1191941239692595321/commands' } fix pls
AlexCdDg
AlexCdDg5mo ago
Option names cannot have uppercase letters
Anthonyo
Anthonyo5mo ago
for which? description? @AlexCdDg
AlexCdDg
AlexCdDg5mo ago
assetId has an uppercase letter
Anthonyo
Anthonyo5mo ago
but nothing is uppercase tho? lmao ohh
AlexCdDg
AlexCdDg5mo ago
assetId
Anthonyo
Anthonyo5mo ago
yooo
AlexCdDg
AlexCdDg5mo ago
it should be assetid
Anthonyo
Anthonyo5mo ago
thank you man
AlexCdDg
AlexCdDg5mo ago
no problem 👍