From 4f265f44e210102bf9a9efa4bc847ed3755336dd Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 27 Dec 2024 00:38:35 +1300 Subject: [PATCH] Minor cleanup --- Commands/AdminCommands.cs | 6 +----- Interviewer.cs | 17 +++++------------ SupportChild.cs | 5 ----- SupportChild.csproj | 1 - 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/Commands/AdminCommands.cs b/Commands/AdminCommands.cs index 452bd80..5d5eed0 100644 --- a/Commands/AdminCommands.cs +++ b/Commands/AdminCommands.cs @@ -4,7 +4,6 @@ using System.ComponentModel; using System.IO; using System.Linq; using System.Net.Http; -using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using DSharpPlus.Commands; @@ -15,9 +14,6 @@ using DSharpPlus.Exceptions; using DSharpPlus.Interactivity; using DSharpPlus.Interactivity.Extensions; using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Schema; -using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs; namespace SupportChild.Commands; @@ -261,7 +257,7 @@ public class AdminCommands { //NullValueHandling = NullValueHandling.Include, MissingMemberHandling = MissingMemberHandling.Error, - Error = delegate (object sender, ErrorEventArgs args) + Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs args) { // I noticed the main exception mainly has information for developers, not administrators, // so I switched to using the inner message if available. diff --git a/Interviewer.cs b/Interviewer.cs index ada880a..5f175da 100644 --- a/Interviewer.cs +++ b/Interviewer.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; -using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -582,19 +581,13 @@ public static class Interviewer DiscordChannel channel, DiscordMessage answerMessage = null) { - // The error message type should not alter anything about the interview + // The error message type should not alter anything about the interview. if (nextQuestion.type != QuestionType.ERROR) { previousQuestion.answer = answer; - if (answerMessage == null) - { - // The answer was provided using a button or selector - previousQuestion.answerID = 0; - } - else - { - previousQuestion.answerID = answerMessage.Id; - } + + // There is no message ID if the question is not a text input. + previousQuestion.answerID = answerMessage == null ? 0 : answerMessage.Id; } // Create next question, or finish the interview. @@ -686,7 +679,7 @@ public static class Interviewer private static async Task DeletePreviousMessages(InterviewQuestion interviewRoot, DiscordChannel channel) { - List previousMessages = new List { }; + List previousMessages = []; interviewRoot.GetMessageIDs(ref previousMessages); foreach (ulong previousMessageID in previousMessages) diff --git a/SupportChild.cs b/SupportChild.cs index 908b109..a811c97 100644 --- a/SupportChild.cs +++ b/SupportChild.cs @@ -12,12 +12,7 @@ using DSharpPlus.Commands; using Microsoft.Extensions.Logging; using SupportChild.Commands; using CommandLine; -using DSharpPlus.Commands.ContextChecks; -using DSharpPlus.Commands.EventArgs; -using DSharpPlus.Commands.Exceptions; using DSharpPlus.Commands.Processors.SlashCommands; -using DSharpPlus.Commands.Processors.TextCommands.Parsing; -using DSharpPlus.Entities; using DSharpPlus.Exceptions; using Microsoft.Extensions.DependencyInjection; diff --git a/SupportChild.csproj b/SupportChild.csproj index 4339399..d6572ad 100644 --- a/SupportChild.csproj +++ b/SupportChild.csproj @@ -42,7 +42,6 @@ -