1
0
mirror of https://github.com/mgerb/ServerStatus synced 2026-01-10 19:22:49 +00:00

more adjustments

This commit is contained in:
2017-01-16 06:42:28 +01:00
parent c39c2b67e1
commit d9d7bf58dd
8 changed files with 10 additions and 8 deletions

View File

@@ -1,53 +0,0 @@
package bot
import (
"fmt"
"github.com/bwmarrin/discordgo"
)
// Variables used for command line parameters
var (
BotID string
Session *discordgo.Session
)
func Connect(token string) {
// Create a new Discord session using the provided bot token.
var err error
Session, err = discordgo.New("Bot " + token)
if err != nil {
fmt.Println("error creating Discord session,", err)
return
}
// Get the account information.
u, err := Session.User("@me")
if err != nil {
fmt.Println("error obtaining account details,", err)
}
// Store the account ID for later use.
BotID = u.ID
fmt.Println("Bot connected")
}
func Start() {
// Open the websocket and begin listening.
err := Session.Open()
if err != nil {
fmt.Println("error opening connection,", err)
return
}
fmt.Println("Bot is now running. Press CTRL-C to exit.")
// Simple way to keep program running until CTRL-C is pressed.
<-make(chan struct{})
return
}
func AddHandler(handler interface{}) {
Session.AddHandler(handler)
}