Discord: Added a helper HasFlag function

This commit is contained in:
diamondburned (Forefront) 2020-05-04 23:13:15 -07:00
parent 9a8b9baa9b
commit 3536ae4cb6
4 changed files with 10 additions and 3 deletions

View File

@ -2,3 +2,10 @@
// does not (and should not) contain API-specific structures, or WS-specific
// structures.
package discord
// HasFlag is returns true if has is in the flag. In other words, it checks if
// has is OR'd into flag. This function could be used for different constants
// such as Permission.
func HasFlag(flag, has uint64) bool {
return flag&has == has
}

View File

@ -81,7 +81,7 @@ const (
GuildDiscoveryRequalifiedMessage
)
type MessageFlags uint8
type MessageFlags uint32
const (
CrosspostedMessage MessageFlags = 1 << iota

View File

@ -111,7 +111,7 @@ const (
)
func (p Permissions) Has(perm Permissions) bool {
return (p & perm) == perm
return HasFlag(uint64(p), uint64(perm))
}
func (p Permissions) Add(perm Permissions) Permissions {

View File

@ -155,7 +155,7 @@ const (
CustomActivity
)
type ActivityFlags uint8
type ActivityFlags uint32
const (
InstanceActivity ActivityFlags = 1 << iota