Cannot set guild permissions to command

Hello, I'm following the doc to set custom permissions to guild commands. https://discordjs.dev/docs/packages/discord.js/14.16.2/ApplicationCommandPermissionsManager:Class#set I reproduce the same line of code as the doc but I get an error.
await guild.commands.permissions.set({
token: 'TotallyRealToken', permissions: [
{
id: '123456789012345678',
permissions: /* <-- this property is in error */ [{
id: '876543210987654321',
type: ApplicationCommandPermissionType.User,
permission: false,
}],
},
]
})
await guild.commands.permissions.set({
token: 'TotallyRealToken', permissions: [
{
id: '123456789012345678',
permissions: /* <-- this property is in error */ [{
id: '876543210987654321',
type: ApplicationCommandPermissionType.User,
permission: false,
}],
},
]
})
Object literal may only specify known properties, but 'permissions' does not exist in type 'ApplicationCommandPermissions'. Did you mean to write 'permission'? I'm in version 14.16.2 and I'm using Typescript. Does anybody know how to solve this issue ? Thanks for your help.
No description
14 Replies
d.js toolkit
d.js toolkitā€¢4mo 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!
Gor
GorOPā€¢4mo ago
Please don't mind pinging me when answering ! :) haha seems like it lol :D how ? I literally copy pasted it :( i'm eager to know what code sample should be correct to use šŸ˜… oh i'm wondering btw, what's the difference between these two ? one says that it overrides the command, the other says that it doesn't oh ok! welll actually i still got an error by using the other command : 401: Unauthorized . I checked that the token is correct btw. here are the intents of my bot :
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences
would you have any idea for a solution ? i'm sorry this is new stuff to me. How do i obtain the access token of an admin member of the guild ? it seems like it doesn't work either using my own access token. i still got the error 401 unfortunately and i'm the server owner... lol the ways you said it seems like i wasn't supposed to find the answer x) I just looked up on the internet to obtain it
Gor
GorOPā€¢4mo ago
How-To Authority
YouTube
How to get a discord token
šŸ”‘šŸ¤– How to get a discord token: A Step-by-Step Guide! šŸ¤–šŸ”‘ šŸ“Œ JUMP TO KEY SECTIONS: 0:00 - Introduction 0:11 - What is a Discord Token? 0:44 - How to Get a Discord Token šŸ¤” What is a Discord Token? Your Discord token is a critical piece of information that encrypts your username and password, generated upon creating your Discord account. It acts as...
Gor
GorOPā€¢4mo ago
but it doesn't matter, thanks for your help man, i just won't implement this feature to my bot šŸ‘Œ thanks for the clarifications it's just weird that it still didn't work using my own access token, or at least the one that i obtain that looks like an access token
Amgelo
Amgeloā€¢4mo ago
that's not the oauth2 token that's more like a personal token
Amgelo
Amgeloā€¢4mo ago
oauth2 is like a way for users to authenticate in your application through discord, and it's a full workflow to implement which djs doesn't support and it's the only way to setup command permissions per role/member
Gor
GorOPā€¢4mo ago
is it like what this doc is about ? https://discord.com/developers/docs/topics/oauth2 it sounds like really fun to implement lol
Discord Developer Portal
Discord Developer Portal ā€” API Docs for Bots and Developers
Integrate your service with Discord ā€” whether it's a bot or a game or whatever your wildest imagination can come up with.
Amgelo
Amgeloā€¢4mo ago
you can make them need a permission (like Manage Guild) by default though, "by default" because it can then be changed further manually by admins, or an application through oauth2 with a logged in admin yeah that's the oauth2 discord spec
Gor
GorOPā€¢4mo ago
oh right, but i just wanted to make commands that can be used by certain roles only
Amgelo
Amgeloā€¢4mo ago
yeah that last part I just added are the only ways you can check the roles in runtime and show an error but it'd still show the commands for them, it's not the same as the "native" way
Gor
GorOPā€¢4mo ago
oooh true it's possible to check if the member has a certain role ! i guess that will do hahaha thank you for your help bro !
Amgelo
Amgeloā€¢4mo ago
np :blobreachReverse:
Gor
GorOPā€¢4mo ago
right, it's also possible to do it that way thank you very much for your help guys ! šŸ˜Š
Want results from more Discord servers?
Add your server