-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
37 lines (33 loc) · 863 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"log"
"os"
"os/signal"
"github.com/bwmarrin/discordgo"
"github.com/tpc3/Vanilla/lib/config"
"github.com/tpc3/Vanilla/lib/db"
"github.com/tpc3/Vanilla/lib/handler"
)
var discord *discordgo.Session
func main() {
var err error
discord, err = discordgo.New("Bot " + config.CurrentConfig.Discord.Token)
if err != nil {
log.Fatal("main.go discordgo.New() failed:", err)
}
discord.AddHandler(handler.MessageCreate)
discord.AddHandler(handler.MessageReactionAdd)
err = discord.Open()
if err != nil {
log.Print("Discordgo connection failure:", err)
return
}
discord.UpdateGameStatus(0, config.CurrentConfig.Discord.Status)
log.Print("Started Discordgo")
defer discord.Close()
defer db.Close()
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
<-stop
log.Print("Vanilla is gracefully shutdowning!")
}