-
Notifications
You must be signed in to change notification settings - Fork 0
/
scharsch-bot.go
52 lines (45 loc) · 1.19 KB
/
scharsch-bot.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
48
49
50
51
52
package main
import (
"github.com/Sharktheone/ScharschBot/conf"
"github.com/Sharktheone/ScharschBot/database/dbprovider"
"github.com/Sharktheone/ScharschBot/discord/bot"
"github.com/Sharktheone/ScharschBot/discord/embed/wEmbed"
"github.com/Sharktheone/ScharschBot/srv"
"github.com/Sharktheone/ScharschBot/whitelist/checkroles"
"github.com/robfig/cron"
"log"
"os"
"os/signal"
)
var config = conf.Config
//TODO: Waitlist for whitelist, when server is offline
func main() {
log.Println("Starting ScharschBot")
//pprof.Start()
dbprovider.Connect()
log.Println("Connected to MongoDB")
dcBot := bot.Session
bot.Registration()
if config.Whitelist.Enabled {
checkroles.CheckRoles()
rolesCron := cron.New()
err := rolesCron.AddFunc("0 */10 * * * *", checkroles.CheckRoles)
if err != nil {
log.Fatalf("Error adding RolesCron job: %v", err)
}
rolesCron.Start()
}
wEmbed.BotAvatarURL = dcBot.State.User.AvatarURL("40")
srv.Start()
defer func() {
bot.RemoveCommands()
err := dcBot.Close()
if err != nil {
log.Fatalf("Error closing Discord session: %v", err)
}
}()
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
log.Println("Press Ctrl+C to exit")
<-stop
}