mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-16 03:44:26 +00:00
diamondburned (Forefront)
f0102d765f
State: Event handlers now handle all of Ready's Guilds field Session: Added Wait, which blocks until SIGINT or Gateway error
43 lines
831 B
Go
43 lines
831 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/diamondburned/arikawa/bot"
|
|
)
|
|
|
|
// To run, do `BOT_TOKEN="TOKEN HERE" go run .`
|
|
|
|
func main() {
|
|
var token = os.Getenv("BOT_TOKEN")
|
|
if token == "" {
|
|
log.Fatalln("No $BOT_TOKEN given.")
|
|
}
|
|
|
|
commands := &Bot{}
|
|
|
|
wait, err := bot.Start(token, commands, func(ctx *bot.Context) error {
|
|
ctx.Prefix = "!"
|
|
|
|
// Subcommand demo, but this can be in another package.
|
|
ctx.MustRegisterSubcommand(&Debug{})
|
|
|
|
return nil
|
|
})
|
|
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
log.Println("Bot started")
|
|
|
|
// As of this commit, wait() will block until SIGINT or fatal. The past
|
|
// versions close on call, but this one will block.
|
|
// If for some reason you want the Cancel() function, manually make a new
|
|
// context.
|
|
if err := wait(); err != nil {
|
|
log.Fatalln("Gateway fatal error:", err)
|
|
}
|
|
}
|