Fetching Guild Commands returns nothing

I am using the ApplicationCommandPermissionsUpdate event. I am trying to fetch the command using the guild.commands.fetch() method. This always returns empty and i'm not sure why. Here is my some code for the ApplicationCommandPermissionsUpdate file:
module.exports = {
name: Events.ApplicationCommandPermissionsUpdate,
on: true,
/** @param {ApplicationCommand} data @param {Client} client */
async execute(data, client) {
//STUFF HAPPENS HERE
let command;

try {
command = await guild.commands.fetch({ force: true });
console.log(command);
console.log(command.map(c => c.name));
} catch (error) {
return console.log(error);
};

//STUFF HAPPENS AFTER HERE
},
};
module.exports = {
name: Events.ApplicationCommandPermissionsUpdate,
on: true,
/** @param {ApplicationCommand} data @param {Client} client */
async execute(data, client) {
//STUFF HAPPENS HERE
let command;

try {
command = await guild.commands.fetch({ force: true });
console.log(command);
console.log(command.map(c => c.name));
} catch (error) {
return console.log(error);
};

//STUFF HAPPENS AFTER HERE
},
};
Output for the logged collection, array and error
Collection(0) [Map] {}
[]
//No error
Collection(0) [Map] {}
[]
//No error
Please note that there are application commands in the server
9 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
PAdventures
PAdventuresOP2y ago
I am only forcing the fetch cuz i dont know what to do. by default i do not add this when fetching objects
space
space2y ago
What are you trying to achieve?
PAdventures
PAdventuresOP2y ago
this is for a logging system. I am only trying to get the command object to access the command name.
PAdventures
PAdventuresOP2y ago
+ id but i get that anyways from what my output says that i understand. the server has no commands in it
space
space2y ago
Yeah, there are no guild commands that your app created there. I'm not sure whether you can fetch another application's command. For your app's global commands you'd need to fetch them on the command manager from your client object.
PAdventures
PAdventuresOP2y ago
client.application.commands.set(commandsArray); this is probably why. I don't make global commands. no matter. this logging still works with the bot itself. ill just have to ignore when other bot command perms change thanks for the help 🙂
space
space2y ago
Those are global commands. squintEyes Anyway, you're welcome!
PAdventures
PAdventuresOP2y ago
i meant guild commands, sorry
Want results from more Discord servers?
Add your server