From 3a602db94ffa5ff126cacf28a128af48c03e51a5 Mon Sep 17 00:00:00 2001
From: Toastie <toastie@toastiet0ast.com>
Date: Tue, 4 Feb 2025 21:20:19 +1300
Subject: [PATCH] Fix error message when using close command after already
 having set a close reason

---
 Commands/CloseCommand.cs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Commands/CloseCommand.cs b/Commands/CloseCommand.cs
index 957d537..2541b05 100644
--- a/Commands/CloseCommand.cs
+++ b/Commands/CloseCommand.cs
@@ -43,7 +43,15 @@ public class CloseCommand
             .AddComponents(new DiscordButtonComponent(DiscordButtonStyle.Danger, "supportchild_closeconfirm", "Confirm"));
 
         await command.RespondAsync(confirmation);
-        closeReasons.Add(command.Channel.Id, reason);
+
+        if (closeReasons.TryGetValue(command.Channel.Id, out _))
+        {
+            closeReasons[command.Channel.Id] = reason;
+        }
+        else
+        {
+            closeReasons.Add(command.Channel.Id, reason);
+        }
     }
 
     public static async Task OnConfirmed(DiscordInteraction interaction)