Permissions

How can I check whether a specific user has, for example, a manage guild on the corresponding server?
17 Replies
d.js toolkit
d.js toolkit8mo 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! - Marked as resolved by OP
h4ze
h4zeOP8mo ago
This information is available to me
h4ze
h4zeOP8mo ago
No description
darp
darp8mo ago
looks like you're using raw api for API help go to discord.gg/discord-developers or discord.gg/discord-api
h4ze
h4zeOP8mo ago
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;
Squid
Squid8mo ago
v14 is nearly identical, you'd just replace perms with PermissionsBitField and perms.FLAGS.MANAGE_GUILD when PermissionFlagsBits.ManageGuild
h4ze
h4zeOP8mo ago
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
Toast
Toast8mo ago
Darp is just being mistaken there, ignore it.
h4ze
h4zeOP8mo ago
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?
<% user.guilds.forEach(guild => { %>

<tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
<%- guild.icon ? `<img src="https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}" class="card-img-top" style="max-width: 18rem;">` : `<img src="https://cdn.discordapp.com/attachments/765919453766352916/877787616974622770/wCfHtuoejLIbAAAAABJRU5ErkJggg.png" class="card-img-top" style="max-width: 18rem;">` %>
</th>
<td class="px-6 py-4">
<%= guild.name %>
</td>
<td class="px-6 py-4">
<a href="<%= baseUrl %>/guild/overview/<%- guild.id %>" class="font-medium text-blue-600 dark:text-blue-500 hover:underline">Edit</a>
</td>
</tr>

<% }); %>
<% user.guilds.forEach(guild => { %>

<tr class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700">
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
<%- guild.icon ? `<img src="https://cdn.discordapp.com/icons/${guild.id}/${guild.icon}" class="card-img-top" style="max-width: 18rem;">` : `<img src="https://cdn.discordapp.com/attachments/765919453766352916/877787616974622770/wCfHtuoejLIbAAAAABJRU5ErkJggg.png" class="card-img-top" style="max-width: 18rem;">` %>
</th>
<td class="px-6 py-4">
<%= guild.name %>
</td>
<td class="px-6 py-4">
<a href="<%= baseUrl %>/guild/overview/<%- guild.id %>" class="font-medium text-blue-600 dark:text-blue-500 hover:underline">Edit</a>
</td>
</tr>

<% }); %>
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 …
h4ze
h4zeOP8mo ago
No description
h4ze
h4zeOP8mo ago
And then ..
h4ze
h4zeOP8mo ago
No description
h4ze
h4zeOP8mo ago
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 🤞
d.js docs
d.js docs8mo ago
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
h4ze
h4zeOP8mo ago
Yeah that’s the way is test it but nothing working … later this day I will post my complete code and error messages. Hello
h4ze
h4zeOP8mo ago
No description
h4ze
h4zeOP8mo ago
Bääääm! Thank you so mutch
Want results from more Discord servers?
Add your server