#discord.go - trying to check for permissions, always returns false while i do have the required perm

11 messages · Page 1 of 1 (latest)

west storm
#

It should be perms&discordgo.PermissionAdministrator == 8

#

Or != 0

west storm
#

Maybe your perms variable isn’t set right?

west storm
#

No it shouldn’t. Discordgo has almost everything that discord supports and I’ve been using permissions checking forever

#

You could try printing out the value of the bit fields instead of checking if it’s equal to 8, maybe that would help

#

I just don’t remember the flag to print as a bitfield

#

Permissions are just bits, for example the administrator one is

00000000000000100 which has a value of 8 because it’s in binary

#

When you do perms & administrator you’re checking if that bit exists

#

So there’s a way to print out the actual bitfield I just can’t remember the flag. When I get home today if no one else has helped with it I can find you the function

#

Oh perfect

#

Looks like it’s %b

fmt.Printf("%08b\n", 13) will print 00001101