added suggestion command
This commit is contained in:
+14
-9
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
commands "ion606_bot/Bot/Commands"
|
||||
helpers "ion606_bot/Bot/Helpers"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
@@ -25,6 +26,7 @@ var commandHandlers = map[string]func(*discordgo.Session, *discordgo.Interaction
|
||||
"animalgif": commands.HandleAnimalGif,
|
||||
"action": commands.HandleAction,
|
||||
"reactionrole": commands.HandleReactionRole,
|
||||
"suggest": commands.HandleSuggest,
|
||||
}
|
||||
|
||||
// Run starts the Discord bot session and listens for both message and slash command events.
|
||||
@@ -35,12 +37,6 @@ 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)
|
||||
@@ -50,6 +46,11 @@ func Run() {
|
||||
log.Fatal("Error opening Discord session: ", err)
|
||||
}
|
||||
|
||||
_, err = helpers.InitSuggestionDB()
|
||||
if err != nil {
|
||||
log.Printf("Failed to initialize suggestion DB: %v", err)
|
||||
}
|
||||
|
||||
RegisterCommands(discord, "")
|
||||
|
||||
log.Println("Bot running....")
|
||||
@@ -59,10 +60,9 @@ func Run() {
|
||||
signal.Notify(c, os.Interrupt)
|
||||
<-c
|
||||
|
||||
// Save reaction role target map to file on shutdown.
|
||||
err = commands.SaveReactionRoleTarget("reactionRoleTarget.json")
|
||||
err = helpers.CloseDB()
|
||||
if err != nil {
|
||||
log.Println("Error saving reaction role target:", err)
|
||||
log.Println("Error closing suggestion DB:", err)
|
||||
}
|
||||
|
||||
err = discord.Close()
|
||||
@@ -85,6 +85,11 @@ func handleInteractionCreate(s *discordgo.Session, i *discordgo.InteractionCreat
|
||||
commands.HandleReactionRoleModalSubmit(s, i)
|
||||
return
|
||||
}
|
||||
|
||||
if i.ModalSubmitData().CustomID == "suggestion_modal" {
|
||||
commands.HandleSuggestModal(s, i)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Then check for message components (buttons).
|
||||
|
||||
Reference in New Issue
Block a user