From d4be9cb849daea5e74810e553bfd696e0af5ac66 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 27 Dec 2024 16:28:27 +1300 Subject: [PATCH] Made registering a category no longer be a requirement for uploading a template for it --- Commands/CreateButtonPanelCommand.cs | 2 +- Commands/CreateSelectionBoxPanelCommand.cs | 2 +- Commands/InterviewTemplateCommands.cs | 30 ---------------------- Commands/NewCommand.cs | 2 +- Utilities.cs | 2 +- 5 files changed, 4 insertions(+), 34 deletions(-) diff --git a/Commands/CreateButtonPanelCommand.cs b/Commands/CreateButtonPanelCommand.cs index e8a18ac..b857c75 100644 --- a/Commands/CreateButtonPanelCommand.cs +++ b/Commands/CreateButtonPanelCommand.cs @@ -18,7 +18,7 @@ public class CreateButtonPanelCommand public async Task OnExecute(SlashCommandContext command) { DiscordMessageBuilder builder = new DiscordMessageBuilder().WithContent(" "); - List verifiedCategories = await Utilities.GetVerifiedChannels(); + List verifiedCategories = await Utilities.GetVerifiedCategories(); if (verifiedCategories.Count == 0) { diff --git a/Commands/CreateSelectionBoxPanelCommand.cs b/Commands/CreateSelectionBoxPanelCommand.cs index 0a6e6e6..c87e3fa 100644 --- a/Commands/CreateSelectionBoxPanelCommand.cs +++ b/Commands/CreateSelectionBoxPanelCommand.cs @@ -46,7 +46,7 @@ public class CreateSelectionBoxPanelCommand public static async Task> GetSelectComponents(SlashCommandContext command, string placeholder) { - List verifiedCategories = await Utilities.GetVerifiedChannels(); + List verifiedCategories = await Utilities.GetVerifiedCategories(); if (verifiedCategories.Count == 0) { diff --git a/Commands/InterviewTemplateCommands.cs b/Commands/InterviewTemplateCommands.cs index e628dfd..6e2f80d 100644 --- a/Commands/InterviewTemplateCommands.cs +++ b/Commands/InterviewTemplateCommands.cs @@ -38,16 +38,6 @@ public class InterviewTemplateCommands return; } - if (!Database.TryGetCategory(category.Id, out Database.Category _)) - { - await command.RespondAsync(new DiscordEmbedBuilder - { - Color = DiscordColor.Red, - Description = "That category is not registered with the bot." - }, true); - return; - } - string interviewTemplateJSON = Database.GetInterviewTemplateJSON(category.Id); if (interviewTemplateJSON == null) { @@ -123,16 +113,6 @@ public class InterviewTemplateCommands return; } - if (!Database.TryGetCategory(category.Id, out Database.Category _)) - { - await command.RespondAsync(new DiscordEmbedBuilder - { - Color = DiscordColor.Red, - Description = "The category ID in the uploaded JSON structure is not a category registered with the bot, use /addcategory first." - }, true); - return; - } - List errors = []; List warnings = []; template.interview.Validate(ref errors, ref warnings, "interview", 0, 0); @@ -234,16 +214,6 @@ public class InterviewTemplateCommands return; } - if (!Database.TryGetCategory(category.Id, out Database.Category _)) - { - await command.RespondAsync(new DiscordEmbedBuilder - { - Color = DiscordColor.Red, - Description = "That category is not registered with the bot." - }, true); - return; - } - if (!Database.TryGetInterviewTemplate(category.Id, out InterviewQuestion _)) { await command.RespondAsync(new DiscordEmbedBuilder diff --git a/Commands/NewCommand.cs b/Commands/NewCommand.cs index a66beff..832cd6e 100644 --- a/Commands/NewCommand.cs +++ b/Commands/NewCommand.cs @@ -19,7 +19,7 @@ public class NewCommand [Description("Opens a new ticket.")] public async Task OnExecute(SlashCommandContext command) { - List verifiedCategories = await Utilities.GetVerifiedChannels(); + List verifiedCategories = await Utilities.GetVerifiedCategories(); switch (verifiedCategories.Count) { case 0: diff --git a/Utilities.cs b/Utilities.cs index 44ee39f..e528514 100644 --- a/Utilities.cs +++ b/Utilities.cs @@ -54,7 +54,7 @@ public static class Utilities return messages; } - public static async Task> GetVerifiedChannels() + public static async Task> GetVerifiedCategories() { List verifiedCategories = new List(); foreach (Database.Category category in Database.GetAllCategories())