-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (34 loc) · 944 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
38
39
40
41
42
43
package main
import (
"log"
"os"
"os/signal"
"github.com/Mines-Little-Theatre/did-someone-say-lean/app"
"github.com/Mines-Little-Theatre/did-someone-say-lean/persist"
"github.com/Mines-Little-Theatre/did-someone-say-lean/utils"
"github.com/bwmarrin/discordgo"
)
func main() {
bot, err := discordgo.New(utils.ReadEnvRequired("LEAN_TOKEN"))
if err != nil {
log.Fatalln("failed to create bot:", err)
}
store, err := persist.Connect()
if err != nil {
log.Fatalln("failed to connect store:", err)
}
app := app.App{Store: store}
bot.Identify.Intents = discordgo.IntentGuildMessages | discordgo.IntentMessageContent
bot.AddHandler(app.HandleMessageCreate)
err = bot.Open()
if err != nil {
log.Fatalln("failed to open connection:", err)
}
log.Println("Bot is running")
// clean shutdown on CTRL+C
sc := make(chan os.Signal, 1)
signal.Notify(sc, os.Interrupt)
<-sc
log.Println("Shutting down bot")
bot.Close()
}