Empty Array when trying to get Guild Application Commands

I'm trying to retrieve all of the application commands from a discord.js slash command interaction. I have the below code snippet.
// other code above
const commands = await interaction.guild?.commands.fetch();
for (const command of commands?.values() as any) {
console.log(command.name);
}
// other code below
// other code above
const commands = await interaction.guild?.commands.fetch();
for (const command of commands?.values() as any) {
console.log(command.name);
}
// other code below
However, this returns an empty Collection Map. [] Is there a missing permission for the bot? I'm using the slash command /setup to execute the function. I'd expect at least 1 object to be returned wit that being the /setup Guild command.
6 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!
SlinkyPotato
SlinkyPotatoOP14mo ago
Using node v20.9.0
treble/luna
treble/luna14mo ago
did you deploy your commands globally ?
SlinkyPotato
SlinkyPotatoOP14mo ago
These are guild only commands. So no.. is that required ?
treble/luna
treble/luna14mo ago
no but if you get an empty collection, your command is deployed globally
SlinkyPotato
SlinkyPotatoOP14mo ago
Oh ok I’ll double check
Want results from more Discord servers?
Add your server