Discord: Added a helper HasFlag function
This commit is contained in:
parent
9a8b9baa9b
commit
3536ae4cb6
|
@ -2,3 +2,10 @@
|
||||||
// does not (and should not) contain API-specific structures, or WS-specific
|
// does not (and should not) contain API-specific structures, or WS-specific
|
||||||
// structures.
|
// structures.
|
||||||
package discord
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ const (
|
||||||
GuildDiscoveryRequalifiedMessage
|
GuildDiscoveryRequalifiedMessage
|
||||||
)
|
)
|
||||||
|
|
||||||
type MessageFlags uint8
|
type MessageFlags uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CrosspostedMessage MessageFlags = 1 << iota
|
CrosspostedMessage MessageFlags = 1 << iota
|
||||||
|
|
|
@ -111,7 +111,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p Permissions) Has(perm Permissions) bool {
|
func (p Permissions) Has(perm Permissions) bool {
|
||||||
return (p & perm) == perm
|
return HasFlag(uint64(p), uint64(perm))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Permissions) Add(perm Permissions) Permissions {
|
func (p Permissions) Add(perm Permissions) Permissions {
|
||||||
|
|
|
@ -155,7 +155,7 @@ const (
|
||||||
CustomActivity
|
CustomActivity
|
||||||
)
|
)
|
||||||
|
|
||||||
type ActivityFlags uint8
|
type ActivityFlags uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
InstanceActivity ActivityFlags = 1 << iota
|
InstanceActivity ActivityFlags = 1 << iota
|
||||||
|
|
Loading…
Reference in New Issue