mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-09-12 05:06:28 +00:00
This commit adds automatic Intents detection into package bot. When the Start function is used, the intents will be OR'd after running the options callback. This commit also breaks the old "AddIntent" methods to rename them to "AddIntents" for correctness.
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package gateway
|
|
|
|
import "github.com/diamondburned/arikawa/v2/discord"
|
|
|
|
// Intents for the new Discord API feature, documented at
|
|
// https://discordapp.com/developers/docs/topics/gateway#gateway-intents.
|
|
type Intents uint32
|
|
|
|
const (
|
|
IntentGuilds Intents = 1 << iota
|
|
IntentGuildMembers
|
|
IntentGuildBans
|
|
IntentGuildEmojis
|
|
IntentGuildIntegrations
|
|
IntentGuildWebhooks
|
|
IntentGuildInvites
|
|
IntentGuildVoiceStates
|
|
IntentGuildPresences
|
|
IntentGuildMessages
|
|
IntentGuildMessageReactions
|
|
IntentGuildMessageTyping
|
|
IntentDirectMessages
|
|
IntentDirectMessageReactions
|
|
IntentDirectMessageTyping
|
|
)
|
|
|
|
// PrivilegedIntents contains a list of privileged intents that Discord requires
|
|
// bots to have these intents explicitly enabled in the Developer Portal.
|
|
var PrivilegedIntents = []Intents{
|
|
IntentGuildPresences,
|
|
IntentGuildMembers,
|
|
}
|
|
|
|
// Has returns true if i has the given intents.
|
|
func (i Intents) Has(intents Intents) bool {
|
|
return discord.HasFlag(uint64(i), uint64(intents))
|
|
}
|
|
|
|
// IsPrivileged returns true for each of the boolean that indicates the type of
|
|
// the privilege.
|
|
func (i Intents) IsPrivileged() (presences, member bool) {
|
|
// Keep this in sync with PrivilegedIntents.
|
|
return i.Has(IntentGuildPresences), i.Has(IntentGuildMembers)
|
|
}
|