package main import ( "fmt" "os" "os/signal" "syscall" "github.com/bwmarrin/discordgo" "gitea.teamortix.com/chanbakjsd/Milen/commands" "gitea.teamortix.com/chanbakjsd/Milen/db" "gitea.teamortix.com/chanbakjsd/Milen/level" "gitea.teamortix.com/chanbakjsd/Milen/persistent" "gitea.teamortix.com/chanbakjsd/Milen/reactrole" "gitea.teamortix.com/chanbakjsd/Milen/util" ) func main() { cfg := LoadConfig() commands.CommonReplacement = cfg.MacroReplace commands.Macro = cfg.Macro level.Roles = cfg.LevelRoles util.ReportTarget = cfg.ReportTarget dg, err := discordgo.New("Bot " + cfg.Token) if err != nil { fmt.Println("error creating Discord session,", err) return } dg.AddHandler(commands.Event) dg.AddHandler(level.Event) dg.AddHandler(reactrole.EventAdd) dg.AddHandler(reactrole.EventRemove) go level.QueueRoles(dg) go persistent.SaveLoop(dg) err = dg.Open() if err != nil { fmt.Println("error opening connection,", err) return } fmt.Println("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 persistent.Save(dg) err = dg.Close() if err != nil { fmt.Println("error closing connection,", err) } db.Close() }