forked from maeve-oake/northstar-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (31 loc) · 739 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
package main
import (
"log"
"os"
"os/signal"
"github.com/bwmarrin/discordgo"
"github.com/joho/godotenv"
)
func main() {
err := godotenv.Load("bot.env")
if err != nil {
log.Fatal("[FATAL] Error loading environment variables. Make sure you are using the file \"bot.env\"")
}
token := os.Getenv("TOKEN")
if token == "" {
log.Fatal("[FATAL] No Discord Token provided in env as TOKEN")
}
bot, err := discordgo.New("Bot " + token)
if err != nil {
log.Fatal(err)
}
bot.Open()
log.Println("[INFO] NorthstarServers bot is running")
defer bot.Close()
Setup(bot)
log.Println("[INFO] Bot ready")
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
<-c
log.Println("[INFO] Shutting down bot gracefully")
}