Browse Source

Removed MESSAGE_CREATE event handler and opening of websocket infavour
of the example being simple and to the point.
Added a disclaimer regarding visual change to the main README.md.

VagantemNumen 8 years ago
parent
commit
7ff5f4b043
3 changed files with 4 additions and 30 deletions
  1. 4 0
      examples/avatar/README.md
  2. 0 15
      examples/avatar/localfile/main.go
  3. 0 15
      examples/avatar/url/main.go

+ 4 - 0
examples/avatar/README.md

@@ -23,3 +23,7 @@ go build
 ### Usage
 
 Please refer to the README.md inside the example folder for usage of that particular example.
+
+### Note
+
+Please be aware that you will need to login with the account you just changed avatar of to visually see the change. Alternatively you could query the avatar from dicord servers to make sure the change has indeed occured.

+ 0 - 15
examples/avatar/localfile/main.go

@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
-	"time"
 
 	"github.com/bwmarrin/discordgo"
 )
@@ -39,12 +38,6 @@ func main() {
 		return
 	}
 
-	// Register messageCreate as a callback for the messageCreate events.
-	dg.AddHandler(messageCreate)
-
-	// Open the websocket and begin listening.
-	dg.Open()
-
 	bot, err := dg.User("@me")
 	if err != nil {
 		fmt.Println("error fetching the bot details,", err)
@@ -77,11 +70,3 @@ func changeAvatar(s *discordgo.Session) {
 		fmt.Println(err)
 	}
 }
-
-// This function will be called (due to AddHandler above) every time a new
-// message is created on any channel that the autenticated bot has access to.
-func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
-
-	// Print message to stdout.
-	fmt.Printf("%-20s %-20s\n %20s > %s\n", m.ChannelID, time.Now().Format(time.Stamp), m.Author.Username, m.Content)
-}

+ 0 - 15
examples/avatar/url/main.go

@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net/http"
-	"time"
 
 	"github.com/bwmarrin/discordgo"
 )
@@ -39,12 +38,6 @@ func main() {
 		return
 	}
 
-	// Register messageCreate as a callback for the messageCreate events.
-	dg.AddHandler(messageCreate)
-
-	// Open the websocket and begin listening.
-	dg.Open()
-
 	bot, err := dg.User("@me")
 	if err != nil {
 		fmt.Println("error fetching the bot details,", err)
@@ -88,11 +81,3 @@ func changeAvatar(s *discordgo.Session) {
 	}
 
 }
-
-// This function will be called (due to AddHandler above) every time a new
-// message is created on any channel that the autenticated bot has access to.
-func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
-
-	// Print message to stdout.
-	fmt.Printf("%-20s %-20s\n %20s > %s\n", m.ChannelID, time.Now().Format(time.Stamp), m.Author.Username, m.Content)
-}