Error while trying to make command register

Hello, I'm trying to make register-command.js file to store my slash commands in but it returns a error. I'll say right away that I'm totally new to programming so I'm copying code from YT tutorial while trying to understand it. This is the code for register-commands.js
***JS file***
require("dotenv").config();
const {REST, Routes} =require("discord.js");

const commands = [
{
name: "Hey",
description: "Replies with hey",
},
];

const rest = new REST({version: "10"}).setToken(process.env.TOKEN);

(async ()=> {
try{
console.log("Registrování lomítkových příkazů...");

await rest.put(
Routes.applicationGuildCommands(
process.env.CLIENT_ID,
process.env.GUILD_ID
),
{ body: commands }
);

console.log("Lomítkové příkazy zaregistrovány")
}catch(error){
console.log(`!!!Je tady error: ${error}`);
}
})();
***JS file***
require("dotenv").config();
const {REST, Routes} =require("discord.js");

const commands = [
{
name: "Hey",
description: "Replies with hey",
},
];

const rest = new REST({version: "10"}).setToken(process.env.TOKEN);

(async ()=> {
try{
console.log("Registrování lomítkových příkazů...");

await rest.put(
Routes.applicationGuildCommands(
process.env.CLIENT_ID,
process.env.GUILD_ID
),
{ body: commands }
);

console.log("Lomítkové příkazy zaregistrovány")
}catch(error){
console.log(`!!!Je tady error: ${error}`);
}
})();
and this is the error I cannot get rid of (I had checked many times but hadn't found any mistake and I couldn't find any help either)
***Console output***
PS H:\programovani\boti\snad_VaVic_bot> node src/register-commands.js
Registrování lomítkových příkazů...
!!!Je tady error: DiscordAPIError[50035]: Invalid Form Body
name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
***Console output***
PS H:\programovani\boti\snad_VaVic_bot> node src/register-commands.js
Registrování lomítkových příkazů...
!!!Je tady error: DiscordAPIError[50035]: Invalid Form Body
name[APPLICATION_COMMAND_INVALID_NAME]: Command name is invalid
9 Replies
d.js toolkit
d.js toolkit14mo 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
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
Dik522
Dik522OP14mo ago
Excuse me please I'm new to programming so I don't understand the exact terminology. What exactly are you pointing at? 😅
Stibnite
Stibnite14mo ago
const commands = [
{
name: "Hey",
description: "Replies with hey",
},
];
const commands = [
{
name: "Hey",
description: "Replies with hey",
},
];
must be
const commands = [
{
name: "hey",
description: "Replies with hey",
},
];
const commands = [
{
name: "hey",
description: "Replies with hey",
},
];
Change name: "Hey" to name: "hey"
Looped
Looped14mo ago
Make the command name from "Hey" to "hey", they can not contain capitalized letters
Dik522
Dik522OP14mo ago
ok I'll do it and test it but I'm pretty sure that's not the problem because in the code it runs succesfully at least to the line console.log("Registrování lomítkových příkazů..."); because you can see this in console Registrování lomítkových příkazů... but it nevers logs out this message console.log("Lomítkové příkazy zaregistrovány") Or am I wrong?
Looped
Looped14mo ago
This error occurs WHILE registering the comamnds to the API so the above log should work, but wont register the command for you.
Dik522
Dik522OP14mo ago
ok Ok I was wrong (again) thank you so so much for help. Note to myself: Don't focus on single part of code error might be somewhere else even it looks good
Looped
Looped14mo ago
Great 👍
Want results from more Discord servers?
Add your server