diff --git a/discord.go b/discord.go index 74c7887..1f5f5a0 100644 --- a/discord.go +++ b/discord.go @@ -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 { diff --git a/structs.go b/structs.go index dd84fa7..756e221 100644 --- a/structs.go +++ b/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 +}