Start a basic connection to Discord.
parent
8cf6c3b68b
commit
8afc7ffa58
35
buttsbot.go
35
buttsbot.go
|
@ -2,8 +2,43 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Session, _ = discordgo.New()
|
||||||
|
|
||||||
|
func init(){
|
||||||
|
Session.Token = os.Getenv("DISCORD_TOKEN")
|
||||||
|
if Session.Token == "" {
|
||||||
|
flag.StringVar(&Session.Token, "t", "", "Discord Authentication Token")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main () {
|
func main () {
|
||||||
|
var err error
|
||||||
fmt.Println("butts!")
|
fmt.Println("butts!")
|
||||||
|
flag.Parse()
|
||||||
|
if Session.Token == "" {
|
||||||
|
log.Println("You must provide a Discord auth token!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//Open a connection to Discord
|
||||||
|
err = Session.Open()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Error opening connection to Discord, %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
//Wait for a CTRL-C
|
||||||
|
log.Printf("Now running. Press CTRL-C to exit.")
|
||||||
|
sc := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
||||||
|
<-sc
|
||||||
|
Session.Close()
|
||||||
}
|
}
|
Loading…
Reference in New Issue