concord icon indicating copy to clipboard operation
concord copied to clipboard

Easy server member permission checking

Open Macintosh-Fan opened this issue 2 years ago • 1 comments

Describe the feature

Check to see if server member has a permission of some sort.

u64bitmask discord_get_member_permissions(const struct discord_guild_member* member) {
    u64bitmask permissions = 0;
    for (int i = 0; i < member->roles->size; ++i) {
        permissions |= member->roles->array[i].permissions;
    }
    return permissions;
}

Though, maybe a function like bool discord_member_has_permission(const struct discord_guild_member* member, unsigned int code) (maybe unsigned int should be something else) could also be implemented.

Additional context

Discord chat (credit goes to @lcsmuller).

Macintosh-Fan avatar Jul 01 '23 19:07 Macintosh-Fan

I'm not sure where this would be used, since for that you would need the discord_guild_member, which in at least all Discord API responses I know, has permissions field available. As for the messages in #concord-help, it seems like there was a misunderstanding, since the MESSAGE_CREATE event doesn't include a member field

Edit: Nevermind, but Discord's get guild member only returns the IDs of the roles, you'll need to get them fetched, so in my opinion, we should find another approach to get the permissions

ThePedroo avatar Jul 01 '23 19:07 ThePedroo