From be44de1eb3819ff8ea69ede2762dcd4d75c1e853 Mon Sep 17 00:00:00 2001
From: Toastie <toastie@toastiet0ast.com>
Date: Tue, 4 Feb 2025 20:38:34 +1300
Subject: [PATCH] Fix other users being able to answer interview questions in
 selectors and buttons

---
 Interviews/Interviewer.cs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Interviews/Interviewer.cs b/Interviews/Interviewer.cs
index 0bb79a0..163de8d 100644
--- a/Interviews/Interviewer.cs
+++ b/Interviews/Interviewer.cs
@@ -70,6 +70,26 @@ public static class Interviewer
             return;
         }
 
+        if (!Database.TryGetOpenTicket(interaction.Channel.Id, out Database.Ticket ticket))
+        {
+            await interaction.CreateResponseAsync(DiscordInteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder()
+                .AddEmbed(new DiscordEmbedBuilder()
+                    .WithColor(DiscordColor.Red)
+                    .WithDescription("Error: This doesn't seem to be in a ticket channel."))
+                .AsEphemeral());
+            return;
+        }
+
+        if (interaction.User.Id != ticket.creatorID)
+        {
+            await interaction.CreateResponseAsync(DiscordInteractionResponseType.ChannelMessageWithSource, new DiscordInteractionResponseBuilder()
+                .AddEmbed(new DiscordEmbedBuilder()
+                    .WithColor(DiscordColor.Red)
+                    .WithDescription("Only the user who opened this ticket can answer interview questions."))
+                .AsEphemeral());
+            return;
+        }
+
         // Ignore if option was deselected.
         if (interaction.Data.ComponentType is not DiscordComponentType.Button && interaction.Data.Values.Length == 0)
         {