/
discord.go
31 lines (24 loc) · 829 Bytes
/
discord.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
// Package discord provides common structures that the whole repository uses. It
// does not (and should not) contain API-specific structures, or WS-specific
// structures.
package discord
import "fmt"
// HasFlag is returns true if has is in the flag. In other words, it checks if
// has is OR'ed into flag. This function could be used for different constants
// such as Permission.
func HasFlag(flag, has uint64) bool {
return flag&has == has
}
// OverboundError is an error that's returned if any value is too long.
type OverboundError struct {
Count int
Max int
Thing string
}
var _ error = (*OverboundError)(nil)
func (e *OverboundError) Error() string {
if e.Thing == "" {
return fmt.Sprintf("Overbound error: %d > %d", e.Count, e.Max)
}
return fmt.Sprintf(e.Thing+" overbound: %d > %d", e.Count, e.Max)
}