2020-01-19 06:06:00 +00:00
|
|
|
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{}
|
|
|
|
|
2020-03-01 02:13:58 +00:00
|
|
|
wait, err := bot.Start(token, commands, func(ctx *bot.Context) error {
|
2020-04-06 20:25:42 +00:00
|
|
|
ctx.HasPrefix = bot.NewPrefix("!", "~")
|
2020-05-15 01:52:15 +00:00
|
|
|
ctx.EditableCommands = true
|
2020-01-24 03:17:03 +00:00
|
|
|
|
|
|
|
// Subcommand demo, but this can be in another package.
|
|
|
|
ctx.MustRegisterSubcommand(&Debug{})
|
|
|
|
|
2020-01-19 06:06:00 +00:00
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Bot started")
|
|
|
|
|
2020-03-01 02:13:58 +00:00
|
|
|
// 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)
|
|
|
|
}
|
2020-01-19 06:06:00 +00:00
|
|
|
}
|