forked from andersfylling/disgord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flag.go
47 lines (36 loc) · 749 Bytes
/
flag.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package disgord
//go:generate stringer -type=Flag
type Flag uint32
func (f Flag) Ignorecache() bool {
return (f & IgnoreCache) > 0
}
func (f Flag) IgnoreEmptyParams() bool {
return (f & IgnoreEmptyParams) > 0
}
func (f Flag) Sort() bool {
flags := SortByID | SortByName
flags |= OrderAscending | OrderDescending
return (f & flags) > 0
}
const (
IgnoreCache Flag = 1 << iota
IgnoreEmptyParams
// sort options
SortByID
SortByName
SortByHoist
SortByGuildID
SortByChannelID
// ordering
OrderAscending // default when sorting
OrderDescending
)
func mergeFlags(flags []Flag) (f Flag) {
for i := range flags {
f |= flags[i]
}
return f
}
func ignoreCache(flags ...Flag) bool {
return (mergeFlags(flags) & IgnoreCache) > 0
}