Merge pull request #763 from lukasz-horonziak/intents
Basic support for Gateway Intents
This commit is contained in:
commit
bfbd4bc5c3
2 changed files with 48 additions and 0 deletions
|
@ -74,6 +74,7 @@ func New(args ...interface{}) (s *Session, err error) {
|
|||
s.Identify.GuildSubscriptions = true
|
||||
s.Identify.Properties.OS = runtime.GOOS
|
||||
s.Identify.Properties.Browser = "DiscordGo v" + VERSION
|
||||
s.Identify.Intents = MakeIntent(IntentsAllWithoutPrivileged)
|
||||
|
||||
// If no arguments are passed return the empty Session interface.
|
||||
if args == nil {
|
||||
|
|
47
structs.go
47
structs.go
|
@ -959,6 +959,7 @@ type Identify struct {
|
|||
Shard *[2]int `json:"shard,omitempty"`
|
||||
Presence GatewayStatusUpdate `json:"presence,omitempty"`
|
||||
GuildSubscriptions bool `json:"guild_subscriptions"`
|
||||
Intents *Intent `json:"intents,omitempty"`
|
||||
}
|
||||
|
||||
// IdentifyProperties contains the "properties" portion of an Identify packet
|
||||
|
@ -1102,3 +1103,49 @@ const (
|
|||
|
||||
ErrCodeReactionBlocked = 90001
|
||||
)
|
||||
|
||||
// Intent is the type of a Gateway Intent
|
||||
// https://discord.com/developers/docs/topics/gateway#gateway-intents
|
||||
type Intent int
|
||||
|
||||
// Constants for the different bit offsets of intents
|
||||
const (
|
||||
IntentsGuilds Intent = 1 << iota
|
||||
IntentsGuildMembers
|
||||
IntentsGuildBans
|
||||
IntentsGuildEmojis
|
||||
IntentsGuildIntegrations
|
||||
IntentsGuildWebhooks
|
||||
IntentsGuildInvites
|
||||
IntentsGuildVoiceStates
|
||||
IntentsGuildPresences
|
||||
IntentsGuildMessages
|
||||
IntentsGuildMessageReactions
|
||||
IntentsGuildMessageTyping
|
||||
IntentsDirectMessages
|
||||
IntentsDirectMessageReactions
|
||||
IntentsDirectMessageTyping
|
||||
|
||||
IntentsAllWithoutPrivileged = IntentsGuilds |
|
||||
IntentsGuildBans |
|
||||
IntentsGuildEmojis |
|
||||
IntentsGuildIntegrations |
|
||||
IntentsGuildWebhooks |
|
||||
IntentsGuildInvites |
|
||||
IntentsGuildVoiceStates |
|
||||
IntentsGuildMessages |
|
||||
IntentsGuildMessageReactions |
|
||||
IntentsGuildMessageTyping |
|
||||
IntentsDirectMessages |
|
||||
IntentsDirectMessageReactions |
|
||||
IntentsDirectMessageTyping
|
||||
IntentsAll = IntentsAllWithoutPrivileged |
|
||||
IntentsGuildMembers |
|
||||
IntentsGuildPresences
|
||||
IntentsNone Intent = 0
|
||||
)
|
||||
|
||||
// MakeIntent helps convert a gateway intent value for use in the Identify structure.
|
||||
func MakeIntent(intents Intent) *Intent {
|
||||
return &intents
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue