Discord Permissions String to Array

Kommentare

2 Kommentare

  • Fen Mammoth

    If you are using a library, it wouldn't surprise me if there is a built-in method to directly check if a given user has the admin perm. Discord.js (https://discordjs.guide/popular-topics/permissions.html) and Discord.py (https://discordpy.readthedocs.io/en/latest/ext/commands/api.html) both do.

    However, if you are writing a pure API implementation, you'll need to use bitwise operations to extract the relevant values. You should definitely read the API docs on permissions (https://discord.com/developers/docs/topics/permissions). The pseudo-code to check for the admin perm (where the permissions variable is an integer) would look something like this:

    (permissions & 0x8) == 0x8

    Building a dictionary of permission values as you described would require writing the bitwise operations for each of the permissions you'd like to extract.

    Though it's not official, I'd recommend joining the main Discord API guild (https://discord.gg/discord-api) if you have further questions about implementing the API or the relevant bit math. Hope that helps! Cheers.

    1
  • Lonely Guy

    Thank you, I will do some research on that.

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.