Kotz's editorconfig styles slightly modified. Target typed new usage. Brackets in expressions used for clarity.

This commit is contained in:
Kwoth
2021-12-26 02:52:09 +01:00
parent 68741ec484
commit d18f9429c6
172 changed files with 921 additions and 494 deletions

View File

@@ -204,7 +204,7 @@ public partial class Utility
{
var q = uow.Quotes.GetById(id);
if (q?.GuildId != ctx.Guild.Id || !hasManageMessages && q.AuthorId != ctx.Message.Author.Id)
if (q?.GuildId != ctx.Guild.Id || (!hasManageMessages && q.AuthorId != ctx.Message.Author.Id))
{
response = GetText(strs.quotes_remove_none);
}
@@ -245,7 +245,7 @@ public partial class Utility
public class ExportedQuote
{
public static ExportedQuote FromModel(Quote quote)
=> new ExportedQuote()
=> new()
{
Id = ((kwum)quote.Id).ToString(),
An = quote.AuthorName,

View File

@@ -126,7 +126,7 @@ public partial class Utility
var when = rem.When;
var diff = when - DateTime.UtcNow;
embed.AddField(
$"#{++i + page * 10} {rem.When:HH:mm yyyy-MM-dd} UTC " +
$"#{++i + (page * 10)} {rem.When:HH:mm yyyy-MM-dd} UTC " +
$"(in {diff.Humanize(2, minUnit: TimeUnit.Minute, culture: _cultureInfo)})",
$@"`Target:` {(rem.IsPrivate ? "DM" : "Channel")}
`TargetId:` {rem.ChannelId}

View File

@@ -111,8 +111,8 @@ public partial class Utility
: TimeSpan.FromDays(1));
if (string.IsNullOrWhiteSpace(message)
|| interval != null &&
(interval.Time > TimeSpan.FromMinutes(25000) || interval.Time < TimeSpan.FromMinutes(1)))
|| (interval != null &&
(interval.Time > TimeSpan.FromMinutes(25000) || interval.Time < TimeSpan.FromMinutes(1))))
{
return;
}

View File

@@ -9,7 +9,7 @@ public class CommandMapService : IInputTransformer, INService
{
private readonly IEmbedBuilderService _eb;
public ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>> AliasMaps { get; } = new ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>>();
public ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>> AliasMaps { get; } = new();
private readonly DbService _db;

View File

@@ -12,7 +12,7 @@ public class ConverterService : INService
.MapJson<ConvertUnit[]>();
private readonly Timer _currencyUpdater;
private readonly TimeSpan _updateInterval = new TimeSpan(12, 0, 0);
private readonly TimeSpan _updateInterval = new(12, 0, 0);
private readonly DbService _db;
private readonly IDataCache _cache;
private readonly IHttpClientFactory _httpFactory;

View File

@@ -11,10 +11,10 @@ namespace NadekoBot.Modules.Utility.Services;
public class PatreonRewardsService : INService
{
private readonly SemaphoreSlim getPledgesLocker = new SemaphoreSlim(1, 1);
private readonly SemaphoreSlim getPledgesLocker = new(1, 1);
private readonly Timer _updater;
private readonly SemaphoreSlim claimLockJustInCase = new SemaphoreSlim(1, 1);
private readonly SemaphoreSlim claimLockJustInCase = new(1, 1);
public TimeSpan Interval { get; } = TimeSpan.FromMinutes(3);
private readonly DbService _db;

View File

@@ -6,7 +6,7 @@ namespace NadekoBot.Modules.Utility.Services;
public class RemindService : INService
{
private readonly Regex _regex = new Regex(@"^(?:in\s?)?\s*(?:(?<mo>\d+)(?:\s?(?:months?|mos?),?))?(?:(?:\sand\s|\s*)?(?<w>\d+)(?:\s?(?:weeks?|w),?))?(?:(?:\sand\s|\s*)?(?<d>\d+)(?:\s?(?:days?|d),?))?(?:(?:\sand\s|\s*)?(?<h>\d+)(?:\s?(?:hours?|h),?))?(?:(?:\sand\s|\s*)?(?<m>\d+)(?:\s?(?:minutes?|mins?|m),?))?\s+(?:to:?\s+)?(?<what>(?:\r\n|[\r\n]|.)+)",
private readonly Regex _regex = new(@"^(?:in\s?)?\s*(?:(?<mo>\d+)(?:\s?(?:months?|mos?),?))?(?:(?:\sand\s|\s*)?(?<w>\d+)(?:\s?(?:weeks?|w),?))?(?:(?:\sand\s|\s*)?(?<d>\d+)(?:\s?(?:days?|d),?))?(?:(?:\sand\s|\s*)?(?<h>\d+)(?:\s?(?:hours?|h),?))?(?:(?:\sand\s|\s*)?(?<m>\d+)(?:\s?(?:minutes?|mins?|m),?))?\s+(?:to:?\s+)?(?<what>(?:\r\n|[\r\n]|.)+)",
RegexOptions.Compiled | RegexOptions.Multiline);
private readonly DiscordSocketClient _client;
@@ -126,7 +126,7 @@ public class RemindService : INService
var ts = new TimeSpan
(
30 * values["mo"] + 7 * values["w"] + values["d"],
(30 * values["mo"]) + (7 * values["w"]) + values["d"],
values["h"],
values["m"],
0

View File

@@ -16,10 +16,10 @@ public sealed class RepeaterService : IReadyExecutor, INService
private readonly IBotCredentials _creds;
private readonly IEmbedBuilderService _eb;
private readonly DiscordSocketClient _client;
private LinkedList<RunningRepeater> _repeaterQueue;
private ConcurrentHashSet<int> _noRedundant;
private readonly LinkedList<RunningRepeater> _repeaterQueue;
private readonly ConcurrentHashSet<int> _noRedundant;
private readonly object _queueLocker = new object();
private readonly object _queueLocker = new();
public RepeaterService(DiscordSocketClient client, DbService db, IBotCredentials creds, IEmbedBuilderService eb)
{

View File

@@ -89,7 +89,7 @@ public sealed class RunningRepeater
// interval (2.4h) * 0.834 is 2.0016 and that is the initial interval
var initialIntervalMultiplier = 1 - (triggerCount - Math.Truncate(triggerCount));
return DateTime.UtcNow + Repeater.Interval * initialIntervalMultiplier;
return DateTime.UtcNow + (Repeater.Interval * initialIntervalMultiplier);
}
public override bool Equals(object obj)

View File

@@ -66,7 +66,7 @@ public partial class Utility
res = res - 273.15m; //celcius!
break;
case "F":
res = res * (9m / 5m) - 459.67m;
res = (res * (9m / 5m)) - 459.67m;
break;
}
}

View File

@@ -58,7 +58,7 @@ public partial class Utility : NadekoModule
if (string.IsNullOrWhiteSpace(game))
return;
if (!(ctx.Guild is SocketGuild socketGuild))
if (ctx.Guild is not SocketGuild socketGuild)
{
Log.Warning("Can't cast guild to socket guild.");
return;
@@ -360,7 +360,7 @@ public partial class Utility : NadekoModule
public Task ShowEmbed(ulong messageId)
=> ShowEmbed((ITextChannel)ctx.Channel, messageId);
private static readonly JsonSerializerOptions _showEmbedSerializerOptions = new JsonSerializerOptions()
private static readonly JsonSerializerOptions _showEmbedSerializerOptions = new()
{
WriteIndented = true,
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
@@ -436,7 +436,7 @@ public partial class Utility : NadekoModule
await ctx.User.SendFileAsync(stream, title, title, false).ConfigureAwait(false);
}
}
private static SemaphoreSlim sem = new SemaphoreSlim(1, 1);
private static SemaphoreSlim sem = new(1, 1);
[NadekoCommand, Aliases]
#if GLOBAL_NADEKO