forked from TeamInklings/Octobot
Fix inspection warnings (#208)
Signed-off-by: neroduckale <100025711+neroduckale@users.noreply.github.com>
This commit is contained in:
parent
4c50bdaff7
commit
bcd1db8c8e
6 changed files with 22 additions and 25 deletions
|
@ -75,7 +75,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), executor, bot, CancellationToken);
|
return await ListRemindersAsync(data.GetOrCreateMemberData(executorId), executor, bot, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> ListRemindersAsync(MemberData data, IUser executor, IUser bot, CancellationToken ct)
|
private Task<Result> ListRemindersAsync(MemberData data, IUser executor, IUser bot, CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (data.Reminders.Count == 0)
|
if (data.Reminders.Count == 0)
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
.WithColour(ColorsList.Red)
|
.WithColour(ColorsList.Red)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
|
return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
var builder = new StringBuilder();
|
var builder = new StringBuilder();
|
||||||
|
@ -101,7 +101,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
.WithColour(ColorsList.Cyan)
|
.WithColour(ColorsList.Cyan)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(
|
return _feedback.SendContextualEmbedResultAsync(
|
||||||
embed, ct);
|
embed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
return await AddReminderAsync(@in, text, data, channelId, executor, CancellationToken);
|
return await AddReminderAsync(@in, text, data, channelId, executor, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> AddReminderAsync(
|
private Task<Result> AddReminderAsync(
|
||||||
TimeSpan @in, string text, GuildData data,
|
TimeSpan @in, string text, GuildData data,
|
||||||
Snowflake channelId, IUser executor, CancellationToken ct = default)
|
Snowflake channelId, IUser executor, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
|
@ -165,7 +165,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
.WithFooter(string.Format(Messages.ReminderPosition, memberData.Reminders.Count))
|
.WithFooter(string.Format(Messages.ReminderPosition, memberData.Reminders.Count))
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
return _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -199,7 +199,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
return await DeleteReminderAsync(data.GetOrCreateMemberData(executorId), position - 1, bot, CancellationToken);
|
return await DeleteReminderAsync(data.GetOrCreateMemberData(executorId), position - 1, bot, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> DeleteReminderAsync(MemberData data, int index, IUser bot,
|
private Task<Result> DeleteReminderAsync(MemberData data, int index, IUser bot,
|
||||||
CancellationToken ct)
|
CancellationToken ct)
|
||||||
{
|
{
|
||||||
if (index >= data.Reminders.Count)
|
if (index >= data.Reminders.Count)
|
||||||
|
@ -208,7 +208,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
.WithColour(ColorsList.Red)
|
.WithColour(ColorsList.Red)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
|
return _feedback.SendContextualEmbedResultAsync(failedEmbed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
var reminder = data.Reminders[index];
|
var reminder = data.Reminders[index];
|
||||||
|
@ -224,7 +224,7 @@ public class RemindCommandGroup : CommandGroup
|
||||||
.WithColour(ColorsList.Green)
|
.WithColour(ColorsList.Green)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(
|
return _feedback.SendContextualEmbedResultAsync(
|
||||||
embed, ct);
|
embed, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class SettingsCommandGroup : CommandGroup
|
||||||
return await SendSettingsListAsync(cfg, bot, page, CancellationToken);
|
return await SendSettingsListAsync(cfg, bot, page, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendSettingsListAsync(JsonNode cfg, IUser bot, int page,
|
private Task<Result> SendSettingsListAsync(JsonNode cfg, IUser bot, int page,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
var description = new StringBuilder();
|
var description = new StringBuilder();
|
||||||
|
@ -124,7 +124,7 @@ public class SettingsCommandGroup : CommandGroup
|
||||||
.WithColour(ColorsList.Red)
|
.WithColour(ColorsList.Red)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(errorEmbed, ct);
|
return _feedback.SendContextualEmbedResultAsync(errorEmbed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
footer.Append($"{Messages.Page} {page}/{totalPages} ");
|
footer.Append($"{Messages.Page} {page}/{totalPages} ");
|
||||||
|
@ -149,7 +149,7 @@ public class SettingsCommandGroup : CommandGroup
|
||||||
.WithFooter(footer.ToString())
|
.WithFooter(footer.ToString())
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
return _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -276,7 +276,7 @@ public class ToolsCommandGroup : CommandGroup
|
||||||
return await ShowGuildInfoAsync(bot, guild, CancellationToken);
|
return await ShowGuildInfoAsync(bot, guild, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct)
|
private Task<Result> ShowGuildInfoAsync(IUser bot, IGuild guild, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var description = new StringBuilder().AppendLine($"## {guild.Name}");
|
var description = new StringBuilder().AppendLine($"## {guild.Name}");
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ public class ToolsCommandGroup : CommandGroup
|
||||||
.WithFooter($"ID: {guild.ID.ToString()}")
|
.WithFooter($"ID: {guild.ID.ToString()}")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
return _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -349,7 +349,7 @@ public class ToolsCommandGroup : CommandGroup
|
||||||
return await SendRandomNumberAsync(first, second, executor, CancellationToken);
|
return await SendRandomNumberAsync(first, second, executor, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendRandomNumberAsync(long first, long? secondNullable,
|
private Task<Result> SendRandomNumberAsync(long first, long? secondNullable,
|
||||||
IUser executor, CancellationToken ct)
|
IUser executor, CancellationToken ct)
|
||||||
{
|
{
|
||||||
const long secondDefault = 0;
|
const long secondDefault = 0;
|
||||||
|
@ -389,7 +389,7 @@ public class ToolsCommandGroup : CommandGroup
|
||||||
.WithColour(embedColor)
|
.WithColour(embedColor)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
return _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly TimestampStyle[] AllStyles =
|
private static readonly TimestampStyle[] AllStyles =
|
||||||
|
@ -435,7 +435,7 @@ public class ToolsCommandGroup : CommandGroup
|
||||||
return await SendTimestampAsync(offset, executor, CancellationToken);
|
return await SendTimestampAsync(offset, executor, CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<Result> SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct)
|
private Task<Result> SendTimestampAsync(TimeSpan? offset, IUser executor, CancellationToken ct)
|
||||||
{
|
{
|
||||||
var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds();
|
var timestamp = DateTimeOffset.UtcNow.Add(offset ?? TimeSpan.Zero).ToUnixTimeSeconds();
|
||||||
|
|
||||||
|
@ -459,6 +459,6 @@ public class ToolsCommandGroup : CommandGroup
|
||||||
.WithColour(ColorsList.Blue)
|
.WithColour(ColorsList.Blue)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
return await _feedback.SendContextualEmbedResultAsync(embed, ct);
|
return _feedback.SendContextualEmbedResultAsync(embed, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,6 @@ public sealed class MemberData
|
||||||
public ulong Id { get; }
|
public ulong Id { get; }
|
||||||
public DateTimeOffset? BannedUntil { get; set; }
|
public DateTimeOffset? BannedUntil { get; set; }
|
||||||
public DateTimeOffset? MutedUntil { get; set; }
|
public DateTimeOffset? MutedUntil { get; set; }
|
||||||
public List<ulong> Roles { get; set; } = new();
|
public List<ulong> Roles { get; set; } = [];
|
||||||
public List<Reminder> Reminders { get; } = new();
|
public List<Reminder> Reminders { get; } = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public sealed class GuildDataService : IHostedService
|
||||||
SaveAsync(CancellationToken.None).GetAwaiter().GetResult();
|
SaveAsync(CancellationToken.None).GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SaveAsync(CancellationToken ct)
|
public Task SaveAsync(CancellationToken ct)
|
||||||
{
|
{
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
var datas = _datas.Values.ToArray();
|
var datas = _datas.Values.ToArray();
|
||||||
|
@ -53,7 +53,7 @@ public sealed class GuildDataService : IHostedService
|
||||||
SerializeObjectSafelyAsync(memberData, $"{data.MemberDataPath}/{memberData.Id}.json", ct)));
|
SerializeObjectSafelyAsync(memberData, $"{data.MemberDataPath}/{memberData.Id}.json", ct)));
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.WhenAll(tasks);
|
return Task.WhenAll(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task SerializeObjectSafelyAsync<T>(T obj, string path, CancellationToken ct)
|
private static async Task SerializeObjectSafelyAsync<T>(T obj, string path, CancellationToken ct)
|
||||||
|
|
|
@ -26,10 +26,7 @@ public sealed class SongUpdateService : BackgroundService
|
||||||
("Squid Sisters", "Ink Me Up", new TimeSpan(0, 2, 13))
|
("Squid Sisters", "Ink Me Up", new TimeSpan(0, 2, 13))
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly List<Activity> _activityList = new(1)
|
private readonly List<Activity> _activityList = [new Activity("with Remora.Discord", ActivityType.Game)];
|
||||||
{
|
|
||||||
new Activity("with Remora.Discord", ActivityType.Game)
|
|
||||||
};
|
|
||||||
|
|
||||||
private readonly DiscordGatewayClient _client;
|
private readonly DiscordGatewayClient _client;
|
||||||
private readonly GuildDataService _guildData;
|
private readonly GuildDataService _guildData;
|
||||||
|
|
Reference in a new issue