2019-11-17 14:47:34 +07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
2019-11-20 12:59:48 +07:00
|
|
|
|
|
|
|
"PermissionGacha/db"
|
2019-11-27 10:40:31 +07:00
|
|
|
"PermissionGacha/modules/active"
|
|
|
|
"PermissionGacha/modules/commands"
|
2019-12-13 10:07:39 +07:00
|
|
|
"PermissionGacha/modules/config"
|
2019-11-27 09:07:48 +07:00
|
|
|
"PermissionGacha/modules/level"
|
|
|
|
"PermissionGacha/modules/starboard"
|
2019-11-17 14:47:34 +07:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2019-12-13 10:07:39 +07:00
|
|
|
dg, err := discordgo.New(config.BotToken)
|
2019-11-17 14:47:34 +07:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Error creating Discord session:", err)
|
|
|
|
return
|
|
|
|
}
|
2019-11-27 10:40:31 +07:00
|
|
|
dg.AddHandler(active.Reward)
|
|
|
|
dg.AddHandler(commands.Parse)
|
|
|
|
dg.AddHandler(commands.ListenPrestigeReact)
|
2019-11-27 09:07:48 +07:00
|
|
|
dg.AddHandler(starboard.ReactListener)
|
2019-11-17 14:47:34 +07:00
|
|
|
err = dg.Open()
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Error opening Discord session:", err)
|
2019-11-20 08:14:36 +07:00
|
|
|
return
|
2019-11-17 14:47:34 +07:00
|
|
|
}
|
2019-11-27 09:07:48 +07:00
|
|
|
go level.ScheduleUpdates(dg)
|
2019-11-17 14:47:34 +07:00
|
|
|
|
|
|
|
sc := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill)
|
|
|
|
<-sc
|
|
|
|
|
|
|
|
dg.Close()
|
|
|
|
db.Close()
|
|
|
|
}
|