1
0
mirror of https://github.com/mgerb/go-discord-bot synced 2026-01-10 17:12:48 +00:00

switched to gin - use logrus

This commit is contained in:
2018-02-06 18:54:13 +00:00
parent 74976de6cf
commit 5b6d74149d
12 changed files with 116 additions and 212 deletions

View File

@@ -1,10 +1,8 @@
package bot
import (
"fmt"
"log"
"github.com/bwmarrin/discordgo"
log "github.com/sirupsen/logrus"
)
// Variables used for command line parameters
@@ -19,7 +17,7 @@ func Connect(token string) {
Session, err = discordgo.New("Bot " + token)
if err != nil {
log.Println(err)
log.Error(err)
log.Fatal("Error creating Discord session.", err)
}
@@ -27,14 +25,14 @@ func Connect(token string) {
u, err := Session.User("@me")
if err != nil {
log.Println("Error obtaining account details. Make sure you have the correct bot token.")
log.Error("Error obtaining account details. Make sure you have the correct bot token.")
log.Fatal(err)
}
// Store the account ID for later use.
BotID = u.ID
fmt.Println("Bot connected")
log.Debug("Bot connected")
}
// Start - blocking function that starts a websocket listenting for discord callbacks
@@ -45,11 +43,11 @@ func Start() {
// Open the websocket and begin listening.
err := Session.Open()
if err != nil {
fmt.Println("error opening connection,", err)
log.Error("error opening connection,", err)
return
}
fmt.Println("Bot is now running...")
log.Debug("Bot is now running...")
// Simple way to keep program running until CTRL-C is pressed.
<-make(chan struct{})