what
This commit is contained in:
+15
-2
@@ -1,7 +1,6 @@
|
||||
package bot
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -36,6 +35,12 @@ func Run() {
|
||||
log.Fatal("Error creating Discord session: ", err)
|
||||
}
|
||||
|
||||
// Load reaction role target map from file.
|
||||
err = commands.LoadReactionRoleTarget("reactionRoleTarget.json")
|
||||
if err != nil {
|
||||
log.Printf("No reaction role target config loaded: %v", err)
|
||||
}
|
||||
|
||||
// add event handlers for messages and interactions.
|
||||
discord.AddHandler(newMessage)
|
||||
discord.AddHandler(handleInteractionCreate)
|
||||
@@ -47,11 +52,19 @@ func Run() {
|
||||
|
||||
RegisterCommands(discord, "")
|
||||
|
||||
fmt.Println("Bot running....")
|
||||
log.Println("Bot running....")
|
||||
|
||||
// Wait for interrupt signal.
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, os.Interrupt)
|
||||
<-c
|
||||
|
||||
// Save reaction role target map to file on shutdown.
|
||||
err = commands.SaveReactionRoleTarget("reactionRoleTarget.json")
|
||||
if err != nil {
|
||||
log.Println("Error saving reaction role target:", err)
|
||||
}
|
||||
|
||||
err = discord.Close()
|
||||
if err != nil {
|
||||
log.Println("Error closing Discord session: ", err)
|
||||
|
||||
Reference in New Issue
Block a user