Trying to get custom set permissions for commands in a Guild.
I have defined (https://github.com/NanoAi/discord_bot_snail/blob/main/src/index.ts#L71) commands that should apply globally to any guild the bot joins, they aren't specifically assigned as commands just for the guild.
Currently I'm trying to fetch the custom set permissions a user may have defined so that I can check them when a user doesn't use a Slash Command, but uses a typed "!command args" in via a message instead.
How would I do this?
I have tried
await guild.commands.fetch()
but this gives me an empty list.
Currently I'm trying the following...
But I'm not seeing a way to get the current set permissions for the integration/application here, (even though that section matches Discord).7 Replies
- 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
I ended up creating and calling a sync command so that I can get the CommandIDs from Discord over to my client. Then I use the following...
Which for a command that has custom permissions set up (see image), returns...
However I'm not sure where to go from there that ID doesn't seem like a permissions enum, and even then it simply says "permission: true". Would really appreciate a hand here.
I'm stumped, is there no way to check the permissions of a slash command in a guild if the slash command happens to be defined in the global scope? Since I can use the slash command in the guild, but
await guild.commands.fetch()
is always empty. Not sure what API I'd need to hit for this. Does Discord not reveal this?You can fetch those permissions, see the examples here: https://discordjs.dev/docs/packages/discord.js/14.16.2/ApplicationCommandPermissionsManager:Class#fetch
Thanks for the tip. This will allow me to shorten the code and reduce errors. However I'm still unsure what to do with that ID. The docs say that the ID can be a snowflake for a "role, user, or channel". So I will try to see if I can figure out a request there.
The type tells you for what the id is
Ah thanks! The definition needs to be corrected...
"Whether this permission is for a role or a user"Was confusing me as it doesn't include Channel like it's supposed to.
Seems like it