Global commands not deploying

// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
I tried to add my bot to a friends server and the commands were not there. When I deployed using the deploy-commands.js as written in the discord.js guide the console log said it successfully reloaded the commands but none ever showed up. The bot has the applications.command scope, however when I change the deploy file to use applicationGuildCommands it deployed them correctly and instantly (I moved back to my test server and removed then re-added my bot). I do not believe it is a rate limit as it was my first time doing it today. I am currently using discord.js 14.17.3 and node 22.13.0
62 Replies
d.js toolkit
d.js toolkit4d 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
TheBear259
TheBear259OP4d ago
discord.js 14.17.3 and node 22.13.0
treble/luna
treble/luna4d ago
if you want your commands to be global, deploy globally first of all, then you dont need to deploy them for every guild you also need to restart your discord client for them to show up
TheBear259
TheBear259OP3d ago
Yes sorry I may have explained this poorly These are the steps I do 1: Invite bot to server with bot and applications.commands scope 2: See it does not have any commands 3: run node deploy-commands.js with this code
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);
This code fully runs saying commands were successfully reloaded 4: See it does not have commands still 5: CTRL+R to reset discord 6: Still no commands 7: Change deploy-commands.js to have this code
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
);
8: Commands now show up Why does the global deploy not work? I even tried waiting for an hour plus, which I read wasn't needed anymore and they still never showed up
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Right, so a question first. Is a bot supposed to have all commands when it joins a server? Currently there is only 1 command that I am deploying But when it joins a server it has none
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
// and deploy your commands!
(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {
// And of course, make sure you catch and log any errors!
console.error(error);
}
})();
This is the complete deploy function that runs, and the console logs that it successfully reloaded 1 commands which is all I have But the commands only show up in the integrations tab when I use Guild specific deployment Which I could do for my firneds server but to be scalable it shouldnt need that and I wanna fix it now rather than later
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Ok I will try this This is what I did 1: Kicked bot from server using the integration sever setting 2: ran node deploy-commands.js with global deploy code 3: Created invite link for bot with bot and applications.commands scope, then used it to invite the bot to my test server 4: Checked integrations server setting and tried using slash command, both showed there were no slash commands with the bot 5: CTRL+R to restart client 6: ran node . to launch bot 7: Checked integrations server setting and tried using slash command, both showed there were no slash commands with the bot
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Right, let me ask this. Does the bot need to be running when I add it to a server? When I run node deploy-commands.js that makes a call to discord.dev where the bot is stored or created right?
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Then where does the bot store the commands that get added to it?
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Ok sorry I'm bad at explaining So my understanding is the code I write like index.js handles the logic for the bot like logging in or how to handle a command interaction. But the "memory" of the bot or the actual bot itself is through discord.dev so deploying commands passes the commands to the bot's memory on discord.dev through the API and gets a response of successful Or not I'm trying to understand where parts of the bot are
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Right, cause creating the application on discord.dev creates the bot on their servers similar to making a new user profile on discord. Then I create the mind of the bot with my code and deploy-commands.js saves it to the bots profile So then this issue is discord client side? cause the api is saying I have correctly added that command to my bots profile
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
That doesnt sound familiar what are those? I wasn't asking how to make user commands, this is supposed to be guild commands sorry I was trying to relate and understand how the bot stores info
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Right but it stores the command right? or is the command stored in the guild?
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Ok, so the global commands are then sotred on discord servers and attached or linked to my bot. Then when the bot enters a new discord the global command should enter with it ?
Unknown User
Unknown User3d ago
Message Not Public
Sign In & Join Server To View
TheBear259
TheBear259OP3d ago
Right I understand that, I was trying to understand how discord keeps track of my bot's global commands Like how that data was stored and linked to my bot So knowing that now it seems the issue is it is not getting linked to my bot globally at least
Amgelo
Amgelo3d ago
the bot enters the guild, and then discord knows that its global commands can be available to users in that guild, depending on their permissions and contexts; the commands aren't registered in the guild automatically though, that'd be a whole different thing can you console.log your data being deployed? share it in a bin since it can be large
d.js docs
d.js docs3d ago
To share long code snippets, use a service like gist, sourcebin, pastebin, or similar instead of posting them as large code blocks or files.
TheBear259
TheBear259OP3d ago
Yes I will do that tonight when I have time I am not familiar with sourcebin but Ill figure it out
Amgelo
Amgelo3d ago
you just paste the output, click save and send the link pretty much the same in every bin site
TheBear259
TheBear259OP3d ago
Ok, seems easy Ill do it tonight thanks
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);

console.log(data);
// The put method is used to fully refresh all commands in the guild with the current set
const data = await rest.put(
Routes.applicationCommands(clientId),
{ body: commands },
);

console.log(data);
Would this be what youre looking for? Or should the log be in the rest.put()?
Amgelo
Amgelo3d ago
I think it should be the same but just in case, the input (commands)
TheBear259
TheBear259OP3d ago
https://srcb.in/DAhy4oFIZz Here you go Top is console.log(commands) bottom is console.log(data)
Amgelo
Amgelo3d ago
well you're only deploying one command (/magic) I think you mentioned only one is showing? should be because of that
TheBear259
TheBear259OP3d ago
Yes I only have 1 command the issue is it says it deployed but global deployment doesnt work
Amgelo
Amgelo3d ago
define "doesn't work"
TheBear259
TheBear259OP3d ago
Never shows up in the guild as commands, or on the bot But if I do Guild specific commands they show up and work for the bot
Amgelo
Amgelo3d ago
are you sure you got the right clientId and it isn't deploying to another bot by mistake?
TheBear259
TheBear259OP3d ago
This is my issue Yes I only have 1 bot
Amgelo
Amgelo3d ago
just in case, could you open the developers portal, open your application, go to installation and send what's on "Installation Contexts"
TheBear259
TheBear259OP3d ago
It currently has User and Guild Install
Amgelo
Amgelo3d ago
can you go to the bot's dm and see if the command is there?
TheBear259
TheBear259OP3d ago
Yes it is there, if I try to run it it says unknown integration
Amgelo
Amgelo3d ago
try refreshing your app then use it again
TheBear259
TheBear259OP3d ago
with ctrl+r?
Amgelo
Amgelo3d ago
yes
TheBear259
TheBear259OP3d ago
Ya, still says unknown integration
Amgelo
Amgelo3d ago
you aren't still deploying right? like, running the deploy script while doing these steps
TheBear259
TheBear259OP3d ago
No I am not
Amgelo
Amgelo3d ago
are you running this locally or on a vps? or any other kind of host
TheBear259
TheBear259OP3d ago
Right now it is just locally, but I do have it set up on cybrancee. Currently (like all of today and yesterday) it is on my local desktop
Amgelo
Amgelo3d ago
what does "set up on cybrancee" exactly mean?
TheBear259
TheBear259OP3d ago
It is on a vps but the server is offline and has been offline the past 2 days while I worked on fixing my issue
Amgelo
Amgelo3d ago
just in case you could try with another app I'm clueless
TheBear259
TheBear259OP3d ago
Unless I can do it for free no, I do not have a job and am utlizing a free month of cybrancee while I work on getting a rasberry Pi
Amgelo
Amgelo3d ago
I meant another discord app
TheBear259
TheBear259OP3d ago
Oh like a different pc?
Amgelo
Amgelo3d ago
no, an api app
TheBear259
TheBear259OP3d ago
I do not fully understand how to do that I can try and look into it tonight
Amgelo
Amgelo3d ago
just delete your current one and make another one
TheBear259
TheBear259OP3d ago
Oh ok, ya I will do that tonight and try Sorry I forget they are called applications and not bots technically
Amgelo
Amgelo3d ago
an app contains a bot (and it may contain other things), but what you delete is the app itself, I'm not sure if you can only do the bot but it wouldn't apply for this case either way
TheBear259
TheBear259OP2d ago
Ok, that makes sense. Sorry this is my first foray into development, I will make a new app and use my code and see if it changes anything Ok, after creating a new bot and changing the token and client id in my code to the new bot it works for the new bot I did not delete my old bot Ya after doing some testing it seems my original bot is bugged or something I gave it the same settings as the new one but only the new one joins the server with commands Alright I was able to successfully add the bot to my friends server with the commands, thank you all for the help!

Did you find this page helpful?