From 6006c78e5be5ccd43b01b9efc476d21be67c7feb Mon Sep 17 00:00:00 2001 From: ION606 Date: Mon, 24 Mar 2025 17:15:56 -0400 Subject: [PATCH] fixes --- Bot/Commands/action.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Bot/Commands/action.go b/Bot/Commands/action.go index b5e12fe..ea5fbe0 100644 --- a/Bot/Commands/action.go +++ b/Bot/Commands/action.go @@ -2,6 +2,7 @@ package commands import ( "fmt" + helpers "ion606_bot/Bot/Helpers" "strings" "github.com/bwmarrin/discordgo" @@ -176,16 +177,33 @@ func HandleAction(s *discordgo.Session, i *discordgo.InteractionCreate) { } // Determine the sender mention. - senderID := i.User.ID + senderID := "" if i.Member != nil { senderID = i.Member.User.ID } + + if i.User != nil && senderID == "" { + senderID = i.User.ID + } + + if senderID == "" { + helpers.HandleError(s, i, fmt.Errorf("failed to get sender ID")) + return + } + senderMention := fmt.Sprintf("<@%s>", senderID) + // Determine bot's ID + var botID string + if s.State != nil && s.State.User != nil { + botID = s.State.User.ID + } else { + botID = i.AppID + } + // Check for special cases. responseMessage := fmt.Sprintf("%s %s %s %s", senderMention, actionSelected, receiverMention, symbol) if receiverID != "" { - botID := s.State.User.ID if receiverID == senderID { // Special message for acting on yourself. if special, ok := specialMessages[actionSelected]["self"]; ok {