dorisbot/main.go
2019-07-02 09:02:31 +00:00

56 lines
754 B
Go

package main
import (
"dorisbot/models"
"dorisbot/pkg/config"
"dorisbot/pkg/options"
"dorisbot/pkg/svc/discord"
"fmt"
"log"
)
func init() {
options.RegOptions()
}
func main() {
var err error
opts := options.GetOptions()
if opts.Help {
opts.ShowUsage()
return
}
fmt.Println("Bot Svc")
cc := make(chan bool)
err = config.LoadConfig(opts.Config)
if err != nil {
log.Fatal(err)
}
conf := config.GetConfig()
_, err = models.NewDB(conf.Database)
if err != nil {
log.Fatal(err)
}
err = models.Ping()
if err != nil {
log.Fatal(err)
}
client, err := discord.NewClient(conf.Discord.BotToken)
if err != nil {
log.Fatal(err)
}
err = client.Connect()
if err != nil {
log.Fatal(err)
}
defer client.Close()
<-cc
}