forked from k5342/ikabot3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
47 lines (38 loc) · 1004 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
44
45
46
47
package main
import (
"log"
"os"
"os/signal"
"syscall"
"github.com/joho/godotenv"
"go.uber.org/zap"
"net/http"
_ "net/http/pprof"
)
var (
logger *zap.Logger
scheduleStore ScheduleStore
)
// https://discord.com/oauth2/authorize?client_id=1018084105587544166&scope=bot&permissions=10737436672
func main() {
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
logger, _ = zap.NewProduction()
defer logger.Sync()
go func() {
logger.Sugar().Info(http.ListenAndServe("localhost:6060", nil))
}()
scheduleStore = NewScheduleStore()
scheduleStore.MaybeRefresh()
bot, err := LaunchDiscordBot(os.Getenv("IKABOT3_TOKEN"), os.Getenv("IKABOT3_ALLOW_MESSAGE_CONTENT_INTENT") == "TRUE")
if err != nil {
logger.Sugar().Errorw("bot creation failed", err)
}
logger.Sugar().Info("Bot is now running. Press CTRL-C to exit.")
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-sc
bot.CloseDiscordBot()
}