Browse Source

Add use of intents to examples

Carson Hoffman 4 years ago
parent
commit
0d776e61a1
2 changed files with 7 additions and 0 deletions
  1. 4 0
      examples/airhorn/main.go
  2. 3 0
      examples/pingpong/main.go

+ 4 - 0
examples/airhorn/main.go

@@ -53,6 +53,10 @@ func main() {
 	// Register guildCreate as a callback for the guildCreate events.
 	dg.AddHandler(guildCreate)
 
+	// We need information about guilds (which includes their channels),
+	// messages and voice states.
+	dg.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsGuilds | discordgo.IntentsGuildMessages | discordgo.IntentsGuildVoiceStates)
+
 	// Open the websocket and begin listening.
 	err = dg.Open()
 	if err != nil {

+ 3 - 0
examples/pingpong/main.go

@@ -33,6 +33,9 @@ func main() {
 	// Register the messageCreate func as a callback for MessageCreate events.
 	dg.AddHandler(messageCreate)
 
+	// In this example, we only care about receiving message events.
+	dg.Identify.Intents = discordgo.MakeIntent(discordgo.IntentsGuildMessages)
+
 	// Open a websocket connection to Discord and begin listening.
 	err = dg.Open()
 	if err != nil {