瀏覽代碼

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 年之前
父節點
當前提交
7ff5f4b043
共有 3 個文件被更改,包括 4 次插入30 次删除
  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)
-}