added suggestion command
This commit is contained in:
@@ -1,47 +1,13 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"strings"
|
||||
|
||||
helpers "ion606_bot/Bot/Helpers"
|
||||
|
||||
"github.com/bwmarrin/discordgo"
|
||||
)
|
||||
|
||||
// reactionRoleTarget maps an interaction’s ID to its target message ID
|
||||
var reactionRoleTarget = make(map[string]string)
|
||||
|
||||
// SaveReactionRoleTarget saves the reactionRoleTarget map to a JSON file.
|
||||
func SaveReactionRoleTarget(filename string) error {
|
||||
data, err := json.Marshal(reactionRoleTarget)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to marshal reactionRoleTarget: %w", err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(filename, data, 0644); err != nil {
|
||||
return fmt.Errorf("failed to write reactionRoleTarget file: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// LoadReactionRoleTarget loads the reactionRoleTarget map from a JSON file.
|
||||
func LoadReactionRoleTarget(filename string) error {
|
||||
data, err := os.ReadFile(filename)
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read reactionRoleTarget file: %w", err)
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(data, &reactionRoleTarget); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal reactionRoleTarget: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert the manage roles permission into an int64 pointer for command registration.
|
||||
func manageRolesPerm() *int64 {
|
||||
fmt.Println("checking perms")
|
||||
@@ -214,8 +180,6 @@ func HandleReactionRole(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
||||
if opt := helpers.GetOption(options, "message_id"); opt != nil {
|
||||
if val := opt.StringValue(); val != "" {
|
||||
targetMsgID = val
|
||||
// Store the target message ID keyed by the user's ID.
|
||||
reactionRoleTarget[i.Member.User.ID] = targetMsgID
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,7 +279,7 @@ func HandleReactionRoleModalSubmit(s *discordgo.Session, i *discordgo.Interactio
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
for _, innerComp := range row.Components {
|
||||
textInput, ok := innerComp.(*discordgo.TextInput)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user