Prechádzať zdrojové kódy

Remove support for optional intents

Carson Hoffman 3 rokov pred
rodič
commit
167b649902

+ 1 - 1
examples/airhorn/main.go

@@ -55,7 +55,7 @@ func main() {
 
 	// We need information about guilds (which includes their channels),
 	// messages and voice states.
-	dg.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsGuilds | discordgo.IntentsGuildMessages | discordgo.IntentsGuildVoiceStates)
+	dg.Identify.Intents = discordgo.IntentsGuilds | discordgo.IntentsGuildMessages | discordgo.IntentsGuildVoiceStates
 
 	// Open the websocket and begin listening.
 	err = dg.Open()

+ 1 - 1
examples/pingpong/main.go

@@ -34,7 +34,7 @@ func main() {
 	dg.AddHandler(messageCreate)
 
 	// In this example, we only care about receiving message events.
-	dg.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsGuildMessages)
+	dg.Identify.Intents = discordgo.IntentsGuildMessages
 
 	// Open a websocket connection to Discord and begin listening.
 	err = dg.Open()

+ 1 - 1
examples/voice_receive/main.go

@@ -75,7 +75,7 @@ func main() {
 	defer s.Close()
 
 	// We only really care about receiving voice state updates.
-	s.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsGuildVoiceStates)
+	s.Identify.Intents = discordgo.IntentsGuildVoiceStates
 
 	err = s.Open()
 	if err != nil {

+ 6 - 4
structs.go

@@ -1158,7 +1158,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"`
+	Intents            Intent              `json:"intents"`
 }
 
 // IdentifyProperties contains the "properties" portion of an Identify packet
@@ -1345,7 +1345,9 @@ const (
 	IntentsNone Intent = 0
 )
 
-// MakeIntent helps convert a gateway intent value for use in the Identify structure.
-func MakeIntent(intents Intent) *Intent {
-	return &intents
+// MakeIntent used to help convert a gateway intent value for use in the Identify structure;
+// this was useful to help support the use of a pointer type when intents were optional.
+// This is now a no-op, and is not necessary to use.
+func MakeIntent(intents Intent) Intent {
+	return intents
 }