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("BOT_TOKEN") if token == "" { token = os.Args[1] if token == "" { log.Fatal("No BOT_TOKEN variable set in environment!") } } return token }