2020-01-15 04:56:50 +00:00
|
|
|
// 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
|
2020-05-05 06:13:15 +00:00
|
|
|
|
2022-04-08 10:35:20 +00:00
|
|
|
import "fmt"
|
|
|
|
|
2020-05-05 06:13:15 +00:00
|
|
|
// HasFlag is returns true if has is in the flag. In other words, it checks if
|
2020-11-22 14:48:36 +00:00
|
|
|
// has is OR'ed into flag. This function could be used for different constants
|
2020-05-05 06:13:15 +00:00
|
|
|
// such as Permission.
|
|
|
|
func HasFlag(flag, has uint64) bool {
|
|
|
|
return flag&has == has
|
|
|
|
}
|
2022-04-08 10:35:20 +00:00
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|