Permissions
How can I check whether a specific user has, for example, a manage guild on the corresponding server?
17 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 OPThis information is available to me
looks like you're using raw api
for API help go to discord.gg/discord-developers or discord.gg/discord-api
I don’t understand 😅
I use discord-passport to connect to the api. This is a discord js specific question because everything else works fine. In version 13 my version still worked
const permsOnGuild = new perms(guild.permissions_new);
if(!permsOnGuild.has(perms.FLAGS.MANAGE_GUILD)) return;
v14 is nearly identical, you'd just replace
perms
with PermissionsBitField
and perms.FLAGS.MANAGE_GUILD
when PermissionFlagsBits.ManageGuild
const permsOnGuild = new permissionsbitfield(guild.permissions_new);
if(!permsOnGuild.has(PermissionFlagsBits.ManageGuild)) return;
permissionbitfield is a const to PermissionsBitField …
And what do you mean with raw api?
I build an web app for my bot with express and discord js etc
Darp is just being mistaken there, ignore it.
So does that mean something? And again: I use discord passport as an npm module. Everything works perfectly except for these permission numbers. Anyone have an idea about this? I'd be happy to send you the entire code of the if query
With discord js version 13 the same request still worked 100%
and now he's acting up because of this number. What I need is basically after the servers that the user is on have been listed... of course only those should be displayed on which the user has the corresponding ManageGuild...
maybe another request?
The code on discord js Version 13 looks like this
<% user.guilds.forEach(guild => {
const permsOnGuild = new perms(guild.permissions_new);
if(!permsOnGuild.has(perms.FLAGS.MANAGE_GUILD)) return;
%>
Perms is a constant from ejs and looks on Permissions .. the class in discord js v13
You know what i mean?
Permissions was declared in app.js here …
And then ..
In another file .. this system works perfect but permissionbitfield .. I don’t know how to implant ..
Sorry for my broken englisch .. I hope on help 🤞
RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined
- All SCREAMING_SNAKE_CASE
enums have been changed to PascalCase
- Intents: Intents.FLAGS.GUILD_MESSAGES
-> GatewayIntentBits.GuildMessages
- Permissions: Permissions.FLAGS.SEND_MESSAGES
-> PermissionFlagsBits.SendMessages
Yeah that’s the way is test it but nothing working … later this day I will post my complete code and error messages.
Hello
Bääääm! Thank you so mutch