From bcd1db8c8ec36692b140f482f603cc4d38770c85 Mon Sep 17 00:00:00 2001 From: neroduckale <100025711+neroduckale@users.noreply.github.com> Date: Wed, 6 Dec 2023 00:24:55 +0500 Subject: [PATCH] Fix inspection warnings (#208) Signed-off-by: neroduckale <100025711+neroduckale@users.noreply.github.com> --- src/Commands/RemindCommandGroup.cs | 16 ++++++++-------- src/Commands/SettingsCommandGroup.cs | 6 +++--- src/Commands/ToolsCommandGroup.cs | 12 ++++++------ src/Data/MemberData.cs | 4 ++-- src/Services/GuildDataService.cs | 4 ++-- src/Services/Update/SongUpdateService.cs | 5 +---- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/src/Commands/RemindCommandGroup.cs b/src/Commands/RemindCommandGroup.cs index 7c087e1..79a583b 100644 --- a/src/Commands/RemindCommandGroup.cs +++ b/src/Commands/RemindCommandGroup.cs @@ -75,7 +75,7 @@ public class RemindCommandGroup : CommandGroup return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), executor, bot, CancellationToken); } - private async Task ListRemindersAsync(MemberData data, IUser executor, IUser bot, CancellationToken ct) + private Task ListRemindersAsync(MemberData data, IUser executor, IUser bot, CancellationToken ct) { if (data.Reminders.Count == 0) { @@ -83,7 +83,7 @@ public class RemindCommandGroup : CommandGroup .WithColour(ColorsList.Red) .Build(); - return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct); + return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct); } var builder = new StringBuilder(); @@ -101,7 +101,7 @@ public class RemindCommandGroup : CommandGroup .WithColour(ColorsList.Cyan) .Build(); - return await _feedback.SendContextualEmbedResultAsync( + return _feedback.SendContextualEmbedResultAsync( embed, ct); } @@ -139,7 +139,7 @@ public class RemindCommandGroup : CommandGroup return await AddReminderAsync(@in, text, data, channelId, executor, CancellationToken); } - private async Task AddReminderAsync( + private Task AddReminderAsync( TimeSpan @in, string text, GuildData data, Snowflake channelId, IUser executor, CancellationToken ct = default) { @@ -165,7 +165,7 @@ public class RemindCommandGroup : CommandGroup .WithFooter(string.Format(Messages.ReminderPosition, memberData.Reminders.Count)) .Build(); - return await _feedback.SendContextualEmbedResultAsync(embed, ct); + return _feedback.SendContextualEmbedResultAsync(embed, ct); } /// @@ -199,7 +199,7 @@ public class RemindCommandGroup : CommandGroup return await DeleteReminderAsync(data.GetOrCreateMemberData(executorId), position - 1, bot, CancellationToken); } - private async Task DeleteReminderAsync(MemberData data, int index, IUser bot, + private Task DeleteReminderAsync(MemberData data, int index, IUser bot, CancellationToken ct) { if (index >= data.Reminders.Count) @@ -208,7 +208,7 @@ public class RemindCommandGroup : CommandGroup .WithColour(ColorsList.Red) .Build(); - return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct); + return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct); } var reminder = data.Reminders[index]; @@ -224,7 +224,7 @@ public class RemindCommandGroup : CommandGroup .WithColour(ColorsList.Green) .Build(); - return await _feedback.SendContextualEmbedResultAsync( + return _feedback.SendContextualEmbedResultAsync( embed, ct); } } diff --git a/src/Commands/SettingsCommandGroup.cs b/src/Commands/SettingsCommandGroup.cs index dd0e9e3..60323d7 100644 --- a/src/Commands/SettingsCommandGroup.cs +++ b/src/Commands/SettingsCommandGroup.cs @@ -105,7 +105,7 @@ public class SettingsCommandGroup : CommandGroup return await SendSettingsListAsync(cfg, bot, page, CancellationToken); } - private async Task SendSettingsListAsync(JsonNode cfg, IUser bot, int page, + private Task SendSettingsListAsync(JsonNode cfg, IUser bot, int page, CancellationToken ct = default) { var description = new StringBuilder(); @@ -124,7 +124,7 @@ public class SettingsCommandGroup : CommandGroup .WithColour(ColorsList.Red) .Build(); - return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct); + return _feedback.SendContextualEmbedResultAsync(errorEmbed, ct); } footer.Append($"{Messages.Page} {page}/{totalPages} "); @@ -149,7 +149,7 @@ public class SettingsCommandGroup : CommandGroup .WithFooter(footer.ToString()) .Build(); - return await _feedback.SendContextualEmbedResultAsync(embed, ct); + return _feedback.SendContextualEmbedResultAsync(embed, ct); } /// diff --git a/src/Commands/ToolsCommandGroup.cs b/src/Commands/ToolsCommandGroup.cs index 0cb237a..be4c2c1 100644 --- a/src/Commands/ToolsCommandGroup.cs +++ b/src/Commands/ToolsCommandGroup.cs @@ -276,7 +276,7 @@ public class ToolsCommandGroup : CommandGroup return await ShowGuildInfoAsync(bot, guild, CancellationToken); } - private async Task ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct) + private Task ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct) { var description = new StringBuilder().AppendLine($"## {guild.Name}"); @@ -312,7 +312,7 @@ public class ToolsCommandGroup : CommandGroup .WithFooter($"ID: {guild.ID.ToString()}") .Build(); - return await _feedback.SendContextualEmbedResultAsync(embed, ct); + return _feedback.SendContextualEmbedResultAsync(embed, ct); } /// @@ -349,7 +349,7 @@ public class ToolsCommandGroup : CommandGroup return await SendRandomNumberAsync(first, second, executor, CancellationToken); } - private async Task SendRandomNumberAsync(long first, long? secondNullable, + private Task SendRandomNumberAsync(long first, long? secondNullable, IUser executor, CancellationToken ct) { const long secondDefault = 0; @@ -389,7 +389,7 @@ public class ToolsCommandGroup : CommandGroup .WithColour(embedColor) .Build(); - return await _feedback.SendContextualEmbedResultAsync(embed, ct); + return _feedback.SendContextualEmbedResultAsync(embed, ct); } private static readonly TimestampStyle[] AllStyles = @@ -435,7 +435,7 @@ public class ToolsCommandGroup : CommandGroup return await SendTimestampAsync(offset, executor, CancellationToken); } - private async Task SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct) + private Task SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct) { var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds(); @@ -459,6 +459,6 @@ public class ToolsCommandGroup : CommandGroup .WithColour(ColorsList.Blue) .Build(); - return await _feedback.SendContextualEmbedResultAsync(embed, ct); + return _feedback.SendContextualEmbedResultAsync(embed, ct); } } diff --git a/src/Data/MemberData.cs b/src/Data/MemberData.cs index b63f8ad..0b0cfb2 100644 --- a/src/Data/MemberData.cs +++ b/src/Data/MemberData.cs @@ -18,6 +18,6 @@ public sealed class MemberData public ulong Id { get; } public DateTimeOffset? BannedUntil { get; set; } public DateTimeOffset? MutedUntil { get; set; } - public List Roles { get; set; } = new(); - public List Reminders { get; } = new(); + public List Roles { get; set; } = []; + public List Reminders { get; } = []; } diff --git a/src/Services/GuildDataService.cs b/src/Services/GuildDataService.cs index d76fffc..3cc8cea 100644 --- a/src/Services/GuildDataService.cs +++ b/src/Services/GuildDataService.cs @@ -39,7 +39,7 @@ public sealed class GuildDataService : IHostedService SaveAsync(CancellationToken.None).GetAwaiter().GetResult(); } - public async Task SaveAsync(CancellationToken ct) + public Task SaveAsync(CancellationToken ct) { var tasks = new List(); var datas = _datas.Values.ToArray(); @@ -53,7 +53,7 @@ public sealed class GuildDataService : IHostedService SerializeObjectSafelyAsync(memberData, $"{data.MemberDataPath}/{memberData.Id}.json", ct))); } - await Task.WhenAll(tasks); + return Task.WhenAll(tasks); } private static async Task SerializeObjectSafelyAsync(T obj, string path, CancellationToken ct) diff --git a/src/Services/Update/SongUpdateService.cs b/src/Services/Update/SongUpdateService.cs index f1ef296..c8221fc 100644 --- a/src/Services/Update/SongUpdateService.cs +++ b/src/Services/Update/SongUpdateService.cs @@ -26,10 +26,7 @@ public sealed class SongUpdateService : BackgroundService ("Squid Sisters", "Ink Me Up", new TimeSpan(0, 2, 13)) }; - private readonly List _activityList = new(1) - { - new Activity("with Remora.Discord", ActivityType.Game) - }; + private readonly List _activityList = [new Activity("with Remora.Discord", ActivityType.Game)]; private readonly DiscordGatewayClient _client; private readonly GuildDataService _guildData;