-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscharsch-bot.go
More file actions
58 lines (49 loc) · 1.33 KB
/
Copy pathscharsch-bot.go
File metadata and controls
58 lines (49 loc) · 1.33 KB
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
53
54
55
56
57
58
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/bot/auth"
"github.com/Sharktheone/ScharschBot/discord/embed/wEmbed"
"github.com/Sharktheone/ScharschBot/srv"
"github.com/Sharktheone/ScharschBot/whitelist"
"github.com/Sharktheone/ScharschBot/whitelist/checkroles"
"github.com/robfig/cron"
"log"
"os"
"os/signal"
)
//TODO: Waitlist for whitelist, when server is offline
func main() {
log.Println("Starting ScharschBot")
conf.LoadConf()
bot.Connect()
whitelist.SetupProvider()
//pprof.Start()
dbprovider.Connect()
log.Println("Connected to MongoDB")
dcBot := auth.Session
bot.Registration()
if conf.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
}