Skip to content

Commit bfbd4bc

Browse files
Merge pull request bwmarrin#763 from lukasz-horonziak/intents
Basic support for Gateway Intents
2 parents a853557 + ee7a5ae commit bfbd4bc

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

discord.go

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ func New(args ...interface{}) (s *Session, err error) {
7474
s.Identify.GuildSubscriptions = true
7575
s.Identify.Properties.OS = runtime.GOOS
7676
s.Identify.Properties.Browser = "DiscordGo v" + VERSION
77+
s.Identify.Intents = MakeIntent(IntentsAllWithoutPrivileged)
7778

7879
// If no arguments are passed return the empty Session interface.
7980
if args == nil {

structs.go

+47
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,7 @@ type Identify struct {
959959
Shard *[2]int `json:"shard,omitempty"`
960960
Presence GatewayStatusUpdate `json:"presence,omitempty"`
961961
GuildSubscriptions bool `json:"guild_subscriptions"`
962+
Intents *Intent `json:"intents,omitempty"`
962963
}
963964

964965
// IdentifyProperties contains the "properties" portion of an Identify packet
@@ -1102,3 +1103,49 @@ const (
11021103

11031104
ErrCodeReactionBlocked = 90001
11041105
)
1106+
1107+
// Intent is the type of a Gateway Intent
1108+
// https://discord.com/developers/docs/topics/gateway#gateway-intents
1109+
type Intent int
1110+
1111+
// Constants for the different bit offsets of intents
1112+
const (
1113+
IntentsGuilds Intent = 1 << iota
1114+
IntentsGuildMembers
1115+
IntentsGuildBans
1116+
IntentsGuildEmojis
1117+
IntentsGuildIntegrations
1118+
IntentsGuildWebhooks
1119+
IntentsGuildInvites
1120+
IntentsGuildVoiceStates
1121+
IntentsGuildPresences
1122+
IntentsGuildMessages
1123+
IntentsGuildMessageReactions
1124+
IntentsGuildMessageTyping
1125+
IntentsDirectMessages
1126+
IntentsDirectMessageReactions
1127+
IntentsDirectMessageTyping
1128+
1129+
IntentsAllWithoutPrivileged = IntentsGuilds |
1130+
IntentsGuildBans |
1131+
IntentsGuildEmojis |
1132+
IntentsGuildIntegrations |
1133+
IntentsGuildWebhooks |
1134+
IntentsGuildInvites |
1135+
IntentsGuildVoiceStates |
1136+
IntentsGuildMessages |
1137+
IntentsGuildMessageReactions |
1138+
IntentsGuildMessageTyping |
1139+
IntentsDirectMessages |
1140+
IntentsDirectMessageReactions |
1141+
IntentsDirectMessageTyping
1142+
IntentsAll = IntentsAllWithoutPrivileged |
1143+
IntentsGuildMembers |
1144+
IntentsGuildPresences
1145+
IntentsNone Intent = 0
1146+
)
1147+
1148+
// MakeIntent helps convert a gateway intent value for use in the Identify structure.
1149+
func MakeIntent(intents Intent) *Intent {
1150+
return &intents
1151+
}

0 commit comments

Comments
 (0)