diff --git a/TeamOctolings.Octobot/Commands/AboutCommandGroup.cs b/TeamOctolings.Octobot/Commands/AboutCommandGroup.cs index 9f05af3..dbb8b12 100644 --- a/TeamOctolings.Octobot/Commands/AboutCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/AboutCommandGroup.cs @@ -25,7 +25,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles the command to show information about this bot: /about. /// [UsedImplicitly] -public class AboutCommandGroup : CommandGroup +public sealed class AboutCommandGroup : CommandGroup { private static readonly (string Username, Snowflake Id)[] Developers = [ @@ -36,9 +36,9 @@ private static readonly (string Username, Snowflake Id)[] Developers = private readonly ICommandContext _context; private readonly IFeedbackService _feedback; + private readonly IDiscordRestGuildAPI _guildApi; private readonly GuildDataService _guildData; private readonly IDiscordRestUserAPI _userApi; - private readonly IDiscordRestGuildAPI _guildApi; public AboutCommandGroup( ICommandContext context, GuildDataService guildData, diff --git a/TeamOctolings.Octobot/Commands/BanCommandGroup.cs b/TeamOctolings.Octobot/Commands/BanCommandGroup.cs index 8d90286..69be80f 100644 --- a/TeamOctolings.Octobot/Commands/BanCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/BanCommandGroup.cs @@ -26,7 +26,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles commands related to ban management: /ban and /unban. /// [UsedImplicitly] -public class BanCommandGroup : CommandGroup +public sealed class BanCommandGroup : CommandGroup { private readonly AccessControlService _access; private readonly IDiscordRestChannelAPI _channelApi; diff --git a/TeamOctolings.Octobot/Commands/ClearCommandGroup.cs b/TeamOctolings.Octobot/Commands/ClearCommandGroup.cs index 8a8cb2f..5eace0e 100644 --- a/TeamOctolings.Octobot/Commands/ClearCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/ClearCommandGroup.cs @@ -23,7 +23,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles the command to clear messages in a channel: /clear. /// [UsedImplicitly] -public class ClearCommandGroup : CommandGroup +public sealed class ClearCommandGroup : CommandGroup { private readonly IDiscordRestChannelAPI _channelApi; private readonly ICommandContext _context; @@ -116,7 +116,8 @@ private async Task ClearMessagesAsync( idList.Add(message.ID); var entry = logEntries[currentLogEntry]; - var str = $"{string.Format(Messages.MessageFrom, Mention.User(message.Author))}\n{message.Content.InBlockCode()}"; + var str = + $"{string.Format(Messages.MessageFrom, Mention.User(message.Author))}\n{message.Content.InBlockCode()}"; if (entry.Builder.Length + str.Length > EmbedConstants.MaxDescriptionLength) { logEntries.Add(entry = new ClearedMessageEntry()); diff --git a/TeamOctolings.Octobot/Commands/Events/ErrorLoggingPostExecutionEvent.cs b/TeamOctolings.Octobot/Commands/Events/ErrorLoggingPostExecutionEvent.cs index 7ffc4fe..7409d3b 100644 --- a/TeamOctolings.Octobot/Commands/Events/ErrorLoggingPostExecutionEvent.cs +++ b/TeamOctolings.Octobot/Commands/Events/ErrorLoggingPostExecutionEvent.cs @@ -18,7 +18,7 @@ namespace TeamOctolings.Octobot.Commands.Events; /// Handles error logging for slash command groups. /// [UsedImplicitly] -public class ErrorLoggingPostExecutionEvent : IPostExecutionEvent +public sealed class ErrorLoggingPostExecutionEvent : IPostExecutionEvent { private readonly IFeedbackService _feedback; private readonly ILogger _logger; diff --git a/TeamOctolings.Octobot/Commands/Events/LoggingPreparationErrorEvent.cs b/TeamOctolings.Octobot/Commands/Events/LoggingPreparationErrorEvent.cs index 10a6a1f..9e69a7f 100644 --- a/TeamOctolings.Octobot/Commands/Events/LoggingPreparationErrorEvent.cs +++ b/TeamOctolings.Octobot/Commands/Events/LoggingPreparationErrorEvent.cs @@ -11,7 +11,7 @@ namespace TeamOctolings.Octobot.Commands.Events; /// Handles error logging for slash commands that couldn't be successfully prepared. /// [UsedImplicitly] -public class LoggingPreparationErrorEvent : IPreparationErrorEvent +public sealed class LoggingPreparationErrorEvent : IPreparationErrorEvent { private readonly ILogger _logger; diff --git a/TeamOctolings.Octobot/Commands/InfoCommandGroup.cs b/TeamOctolings.Octobot/Commands/InfoCommandGroup.cs index 65ddd53..d7798f3 100644 --- a/TeamOctolings.Octobot/Commands/InfoCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/InfoCommandGroup.cs @@ -23,7 +23,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles info commands: /userinfo, /guildinfo. /// [UsedImplicitly] -public class InfoCommandGroup : CommandGroup +public sealed class InfoCommandGroup : CommandGroup { private readonly ICommandContext _context; private readonly IFeedbackService _feedback; diff --git a/TeamOctolings.Octobot/Commands/KickCommandGroup.cs b/TeamOctolings.Octobot/Commands/KickCommandGroup.cs index 4252232..a8fea2a 100644 --- a/TeamOctolings.Octobot/Commands/KickCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/KickCommandGroup.cs @@ -22,7 +22,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles the command to kick members of a guild: /kick. /// [UsedImplicitly] -public class KickCommandGroup : CommandGroup +public sealed class KickCommandGroup : CommandGroup { private readonly AccessControlService _access; private readonly IDiscordRestChannelAPI _channelApi; diff --git a/TeamOctolings.Octobot/Commands/MuteCommandGroup.cs b/TeamOctolings.Octobot/Commands/MuteCommandGroup.cs index 8e449f7..282afe8 100644 --- a/TeamOctolings.Octobot/Commands/MuteCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/MuteCommandGroup.cs @@ -26,7 +26,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles commands related to mute management: /mute and /unmute. /// [UsedImplicitly] -public class MuteCommandGroup : CommandGroup +public sealed class MuteCommandGroup : CommandGroup { private readonly AccessControlService _access; private readonly ICommandContext _context; diff --git a/TeamOctolings.Octobot/Commands/PingCommandGroup.cs b/TeamOctolings.Octobot/Commands/PingCommandGroup.cs index 70b9f23..01a1ee2 100644 --- a/TeamOctolings.Octobot/Commands/PingCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/PingCommandGroup.cs @@ -22,7 +22,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles the command to get the time taken for the gateway to respond to the last heartbeat: /ping /// [UsedImplicitly] -public class PingCommandGroup : CommandGroup +public sealed class PingCommandGroup : CommandGroup { private readonly IDiscordRestChannelAPI _channelApi; private readonly DiscordGatewayClient _client; diff --git a/TeamOctolings.Octobot/Commands/RemindCommandGroup.cs b/TeamOctolings.Octobot/Commands/RemindCommandGroup.cs index f40ba6b..e709296 100644 --- a/TeamOctolings.Octobot/Commands/RemindCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/RemindCommandGroup.cs @@ -25,13 +25,19 @@ namespace TeamOctolings.Octobot.Commands; /// Handles commands to manage reminders: /remind, /listremind, /delremind /// [UsedImplicitly] -public class RemindCommandGroup : CommandGroup +public sealed class RemindCommandGroup : CommandGroup { + public enum Parameters + { + [UsedImplicitly] Time, + [UsedImplicitly] Text + } + private readonly IInteractionCommandContext _context; private readonly IFeedbackService _feedback; private readonly GuildDataService _guildData; - private readonly IDiscordRestUserAPI _userApi; private readonly IDiscordRestInteractionAPI _interactionApi; + private readonly IDiscordRestUserAPI _userApi; public RemindCommandGroup( IInteractionCommandContext context, GuildDataService guildData, IFeedbackService feedback, @@ -75,10 +81,12 @@ public async Task ExecuteListReminderAsync() var data = await _guildData.GetData(guildId, CancellationToken); Messages.Culture = GuildSettings.Language.Get(data.Settings); - return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), guildId, executor, bot, CancellationToken); + return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), guildId, executor, bot, + CancellationToken); } - private Task ListRemindersAsync(MemberData data, Snowflake guildId, IUser executor, IUser bot, CancellationToken ct) + private Task ListRemindersAsync(MemberData data, Snowflake guildId, IUser executor, IUser bot, + CancellationToken ct) { if (data.Reminders.Count == 0) { @@ -93,10 +101,12 @@ private Task ListRemindersAsync(MemberData data, Snowflake guildId, IUse for (var i = 0; i < data.Reminders.Count; i++) { var reminder = data.Reminders[i]; - builder.AppendBulletPointLine(string.Format(Messages.ReminderPosition, Markdown.InlineCode((i + 1).ToString()))) + builder.AppendBulletPointLine(string.Format(Messages.ReminderPosition, + Markdown.InlineCode((i + 1).ToString()))) .AppendSubBulletPointLine(string.Format(Messages.ReminderText, Markdown.InlineCode(reminder.Text))) .AppendSubBulletPointLine(string.Format(Messages.ReminderTime, Markdown.Timestamp(reminder.At))) - .AppendSubBulletPointLine(string.Format(Messages.DescriptionActionJumpToMessage, $"https://discord.com/channels/{guildId.Value}/{reminder.ChannelId}/{reminder.MessageId}")); + .AppendSubBulletPointLine(string.Format(Messages.DescriptionActionJumpToMessage, + $"https://discord.com/channels/{guildId.Value}/{reminder.ChannelId}/{reminder.MessageId}")); } var embed = new EmbedBuilder().WithSmallTitle( @@ -120,8 +130,7 @@ private Task ListRemindersAsync(MemberData data, Snowflake guildId, IUse [RequireContext(ChannelContext.Guild)] [UsedImplicitly] public async Task ExecuteReminderAsync( - [Description("After what period of time mention the reminder (e.g. 1h30m)")] - [Option("in")] + [Description("After what period of time mention the reminder (e.g. 1h30m)")] [Option("in")] string timeSpanString, [Description("Reminder text")] [MaxLength(512)] string text) @@ -166,7 +175,9 @@ private async Task AddReminderAsync(TimeSpan timeSpan, string text, Guil { var memberData = data.GetOrCreateMemberData(executor.ID); var remindAt = DateTimeOffset.UtcNow.Add(timeSpan); - var responseResult = await _interactionApi.GetOriginalInteractionResponseAsync(_context.Interaction.ApplicationID, _context.Interaction.Token, ct); + var responseResult = + await _interactionApi.GetOriginalInteractionResponseAsync(_context.Interaction.ApplicationID, + _context.Interaction.Token, ct); if (!responseResult.IsDefined(out var response)) { return (Result)responseResult; @@ -194,12 +205,6 @@ private async Task AddReminderAsync(TimeSpan timeSpan, string text, Guil return await _feedback.SendContextualEmbedResultAsync(embed, ct: ct); } - public enum Parameters - { - [UsedImplicitly] Time, - [UsedImplicitly] Text - } - /// /// A slash command that edits a scheduled reminder using the specified text or time. /// diff --git a/TeamOctolings.Octobot/Commands/SettingsCommandGroup.cs b/TeamOctolings.Octobot/Commands/SettingsCommandGroup.cs index 56584bf..0acaa88 100644 --- a/TeamOctolings.Octobot/Commands/SettingsCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/SettingsCommandGroup.cs @@ -26,7 +26,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles the commands to list and modify per-guild settings: /settings and /settings list. /// [UsedImplicitly] -public class SettingsCommandGroup : CommandGroup +public sealed class SettingsCommandGroup : CommandGroup { /// /// Represents all options as an array of objects implementing . diff --git a/TeamOctolings.Octobot/Commands/ToolsCommandGroup.cs b/TeamOctolings.Octobot/Commands/ToolsCommandGroup.cs index 6af3040..b4c3488 100644 --- a/TeamOctolings.Octobot/Commands/ToolsCommandGroup.cs +++ b/TeamOctolings.Octobot/Commands/ToolsCommandGroup.cs @@ -22,7 +22,7 @@ namespace TeamOctolings.Octobot.Commands; /// Handles tool commands: /random, /timestamp, /8ball. /// [UsedImplicitly] -public class ToolsCommandGroup : CommandGroup +public sealed class ToolsCommandGroup : CommandGroup { private static readonly TimestampStyle[] AllStyles = [ diff --git a/TeamOctolings.Octobot/Responders/GuildLoadedResponder.cs b/TeamOctolings.Octobot/Responders/GuildLoadedResponder.cs index 0c71a06..cebb1ea 100644 --- a/TeamOctolings.Octobot/Responders/GuildLoadedResponder.cs +++ b/TeamOctolings.Octobot/Responders/GuildLoadedResponder.cs @@ -19,7 +19,7 @@ namespace TeamOctolings.Octobot.Responders; /// has enabled /// [UsedImplicitly] -public class GuildLoadedResponder : IResponder +public sealed class GuildLoadedResponder : IResponder { private readonly IDiscordRestChannelAPI _channelApi; private readonly GuildDataService _guildData; diff --git a/TeamOctolings.Octobot/Responders/GuildMemberJoinedResponder.cs b/TeamOctolings.Octobot/Responders/GuildMemberJoinedResponder.cs index 6964fe7..c1f1da0 100644 --- a/TeamOctolings.Octobot/Responders/GuildMemberJoinedResponder.cs +++ b/TeamOctolings.Octobot/Responders/GuildMemberJoinedResponder.cs @@ -18,7 +18,7 @@ namespace TeamOctolings.Octobot.Responders; /// /// [UsedImplicitly] -public class GuildMemberJoinedResponder : IResponder +public sealed class GuildMemberJoinedResponder : IResponder { private readonly IDiscordRestChannelAPI _channelApi; private readonly IDiscordRestGuildAPI _guildApi; diff --git a/TeamOctolings.Octobot/Responders/GuildMemberLeftResponder.cs b/TeamOctolings.Octobot/Responders/GuildMemberLeftResponder.cs index 4f6150c..9774899 100644 --- a/TeamOctolings.Octobot/Responders/GuildMemberLeftResponder.cs +++ b/TeamOctolings.Octobot/Responders/GuildMemberLeftResponder.cs @@ -15,7 +15,7 @@ namespace TeamOctolings.Octobot.Responders; /// /// [UsedImplicitly] -public class GuildMemberLeftResponder : IResponder +public sealed class GuildMemberLeftResponder : IResponder { private readonly IDiscordRestChannelAPI _channelApi; private readonly IDiscordRestGuildAPI _guildApi; diff --git a/TeamOctolings.Octobot/Responders/GuildUnloadedResponder.cs b/TeamOctolings.Octobot/Responders/GuildUnloadedResponder.cs index a4680d4..c73c134 100644 --- a/TeamOctolings.Octobot/Responders/GuildUnloadedResponder.cs +++ b/TeamOctolings.Octobot/Responders/GuildUnloadedResponder.cs @@ -12,7 +12,7 @@ namespace TeamOctolings.Octobot.Responders; /// Handles removing guild ID from if the guild becomes unavailable. /// [UsedImplicitly] -public class GuildUnloadedResponder : IResponder +public sealed class GuildUnloadedResponder : IResponder { private readonly GuildDataService _guildData; private readonly ILogger _logger; diff --git a/TeamOctolings.Octobot/Responders/MessageDeletedResponder.cs b/TeamOctolings.Octobot/Responders/MessageDeletedResponder.cs index 6b09b8d..88a8de2 100644 --- a/TeamOctolings.Octobot/Responders/MessageDeletedResponder.cs +++ b/TeamOctolings.Octobot/Responders/MessageDeletedResponder.cs @@ -18,7 +18,7 @@ namespace TeamOctolings.Octobot.Responders; /// to a guild's if one is set. /// [UsedImplicitly] -public class MessageDeletedResponder : IResponder +public sealed class MessageDeletedResponder : IResponder { private readonly IDiscordRestAuditLogAPI _auditLogApi; private readonly IDiscordRestChannelAPI _channelApi; diff --git a/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs b/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs index 6134214..2968562 100644 --- a/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs +++ b/TeamOctolings.Octobot/Responders/MessageEditedResponder.cs @@ -20,7 +20,7 @@ namespace TeamOctolings.Octobot.Responders; /// to a guild's if one is set. /// [UsedImplicitly] -public class MessageEditedResponder : IResponder +public sealed class MessageEditedResponder : IResponder { private readonly CacheService _cacheService; private readonly IDiscordRestChannelAPI _channelApi; diff --git a/TeamOctolings.Octobot/Responders/MessageReceivedResponder.cs b/TeamOctolings.Octobot/Responders/MessageReceivedResponder.cs index 34a8f5c..24d53a5 100644 --- a/TeamOctolings.Octobot/Responders/MessageReceivedResponder.cs +++ b/TeamOctolings.Octobot/Responders/MessageReceivedResponder.cs @@ -11,7 +11,7 @@ namespace TeamOctolings.Octobot.Responders; /// Handles sending replies to easter egg messages. /// [UsedImplicitly] -public class MessageCreateResponder : IResponder +public sealed class MessageCreateResponder : IResponder { private readonly IDiscordRestChannelAPI _channelApi;