You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
token := getBotToken()
|
|
|
|
discord, err := discordgo.New("Bot " + token)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
InitCommands(discord)
|
|
|
|
InitRoleReactions(discord)
|
|
|
|
|
|
|
|
err = discord.Open()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal("No connection, rip")
|
|
|
|
}
|
|
|
|
defer discord.Close()
|
|
|
|
|
|
|
|
log.Println("Bub is alive!")
|
|
|
|
sc := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
|
|
|
<-sc
|
|
|
|
}
|
|
|
|
|
|
|
|
func getBotToken() string {
|
|
|
|
token := os.Getenv("BUB_TOKEN")
|
|
|
|
if token == "" {
|
|
|
|
token = os.Args[1]
|
|
|
|
if token == "" {
|
|
|
|
log.Fatal("No BOT_TOKEN variable set in environment!")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return token
|
|
|
|
}
|