Start a basic connection to Discord.
parent
8cf6c3b68b
commit
8afc7ffa58
39
buttsbot.go
39
buttsbot.go
|
@ -2,8 +2,43 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"flag"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
"github.com/bwmarrin/discordgo"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main () {
|
var Session, _ = discordgo.New()
|
||||||
fmt.Println("butts!")
|
|
||||||
|
func init(){
|
||||||
|
Session.Token = os.Getenv("DISCORD_TOKEN")
|
||||||
|
if Session.Token == "" {
|
||||||
|
flag.StringVar(&Session.Token, "t", "", "Discord Authentication Token")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main () {
|
||||||
|
var err error
|
||||||
|
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