Discord slash commands aren't registering

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("Registering slash commands...");

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

console.log("Registered succesfully!");
} catch (error) {
console.log(`There is an error: ${error}`);
}
})();
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("Registering slash commands...");

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

console.log("Registered succesfully!");
} catch (error) {
console.log(`There is an error: ${error}`);
}
})();
I followed the tutorial on youtube. I rewatched it. Everything is good with the script. The slash command isn't registering. It isn't showing in the / space. Before you all start, yes i have invited my bot with application command permission, i reinvited it 3 times. I reseted the token. I've ran the script. I have no idea what's wrong.
29 Replies
d.js toolkit
d.js toolkit8mo 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
Mark
Mark8mo ago
Does anything print to console?
Purple Ghost
Purple GhostOP8mo ago
nope only the console.log
Mark
Mark8mo ago
What prints The success message?
Purple Ghost
Purple GhostOP8mo ago
PS C:\Users\Glitc\Documents\Projects\Bot> node src/register-commands.js Registering slash commands... Registered succesfully! PS C:\Users\Glitc\Documents\Projects\Bot> yes the success message
Mark
Mark8mo ago
Make sure the guild id there matches yours, and also reload your user client
Purple Ghost
Purple GhostOP8mo ago
yep, nuffin
Purple Ghost
Purple GhostOP8mo ago
No description
Purple Ghost
Purple GhostOP8mo ago
alright both good client id and guild id both are alright i reloaded the client
Mark
Mark8mo ago
Could try doing a global deploy instead of guild by changing the route, just remove the guild part and take the guild id out as well
Purple Ghost
Purple GhostOP8mo ago
how to global? i'm completely new
Mark
Mark8mo ago
Also, might be worth trying with the deploy script in the d.js guide, not a YouTube tutorial I included the parts that you would need to modify in the message for global commands
Purple Ghost
Purple GhostOP8mo ago
d.js guide is confusing i followed it twice
Mark
Mark8mo ago
When you say new, do you mean to coding or d.js
Purple Ghost
Purple GhostOP8mo ago
d.js i know javascript and html and css and lua not the best but i made a pokemon website as a project fetch data from an api and sum other simple ideas
d.js docs
d.js docs8mo ago
:guide: Creating Your Bot: Registering slash commands The command deployment script, to register your slash commands with Discord so they appear in the interface. read more
Purple Ghost
Purple GhostOP8mo ago
okei T~T imma try the guide once again after i'm done with stuff
Mark
Mark8mo ago
Your put method is incorrect
Purple Ghost
Purple GhostOP8mo ago
oh but for the dude it worked a year ago
Mark
Mark8mo ago
It should be .put(Routes...(), body: {...}) You're closing the put brackets before the body
Purple Ghost
Purple GhostOP8mo ago
oh- uhm aksmldsjfbkdgiufdoivjo'psk[p lac;a:"slamldnsfbdghj i feel embarrased wait lemme check wth
Mark
Mark8mo ago
I pulled up the guide page to compare the code because I thought something was off with yours
Purple Ghost
Purple GhostOP8mo ago
:😭 the gguy did the same i didn't notice it! i swear!!!1111!!! i didn't!
Mark
Mark8mo ago
¯\_(ツ)_/¯
Purple Ghost
Purple GhostOP8mo ago
don't bully me!
Mark
Mark8mo ago
This is why we have the written guide, and it's tested to work. The library maintainers wrote it
Purple Ghost
Purple GhostOP8mo ago
thank you! i'll check the guide from now on! if i encounter problems! thank you! god bless you!
Mark
Mark8mo ago
We're here to help, good luck with your project
Purple Ghost
Purple GhostOP8mo ago
let your pillows be cold(good way) let your food cool down to the perfect spot uh let that you don't burn your mouth let that you always have food! uh have a wonderfull day!

Did you find this page helpful?