mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-12 10:18:27 -04:00
More target-typed new and redundant paranthesis cleanup
This commit is contained in:
@@ -32,7 +32,7 @@ public class CommandMapService : IInputTransformer, INService
|
||||
.Where(x => guildIds.Contains(x.GuildId))
|
||||
.ToList();
|
||||
|
||||
AliasMaps = new ConcurrentDictionary<ulong, ConcurrentDictionary<string, string>>(configs
|
||||
AliasMaps = new(configs
|
||||
.ToDictionary(
|
||||
x => x.GuildId,
|
||||
x => new ConcurrentDictionary<string, string>(x.CommandAliases
|
||||
@@ -88,7 +88,7 @@ public class CommandMapService : IInputTransformer, INService
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(1500).ConfigureAwait(false);
|
||||
await toDelete.DeleteAsync(new RequestOptions()
|
||||
await toDelete.DeleteAsync(new()
|
||||
{
|
||||
RetryMode = RetryMode.AlwaysRetry
|
||||
}).ConfigureAwait(false);
|
||||
|
@@ -33,7 +33,7 @@ public class ConverterService : INService
|
||||
|
||||
if (client.ShardId == 0)
|
||||
{
|
||||
_currencyUpdater = new Timer(async (shouldLoad) => await UpdateCurrency((bool)shouldLoad).ConfigureAwait(false),
|
||||
_currencyUpdater = new(async shouldLoad => await UpdateCurrency((bool)shouldLoad).ConfigureAwait(false),
|
||||
client.ShardId == 0,
|
||||
TimeSpan.Zero,
|
||||
_updateInterval);
|
||||
|
@@ -55,7 +55,7 @@ public class PatreonRewardsService : INService
|
||||
_client = client;
|
||||
|
||||
if (client.ShardId == 0)
|
||||
_updater = new Timer(async _ => await RefreshPledges(_credsProvider.GetCreds()).ConfigureAwait(false),
|
||||
_updater = new(async _ => await RefreshPledges(_credsProvider.GetCreds()).ConfigureAwait(false),
|
||||
null, TimeSpan.Zero, Interval);
|
||||
}
|
||||
|
||||
@@ -188,8 +188,8 @@ public class PatreonRewardsService : INService
|
||||
}
|
||||
|
||||
var userData = members.Join(users,
|
||||
(m) => m.Relationships.User.Data.Id,
|
||||
(u) => u.Id,
|
||||
m => m.Relationships.User.Data.Id,
|
||||
u => u.Id,
|
||||
(m, u) => new
|
||||
{
|
||||
PatreonUserId = m.Relationships.User.Data.Id,
|
||||
@@ -238,7 +238,7 @@ public class PatreonRewardsService : INService
|
||||
|
||||
if (usr is null)
|
||||
{
|
||||
users.Add(new RewardedUser()
|
||||
users.Add(new()
|
||||
{
|
||||
PatreonUserId = patreonUserId,
|
||||
LastReward = now,
|
||||
|
@@ -137,7 +137,7 @@ public class RemindService : INService
|
||||
0
|
||||
);
|
||||
|
||||
obj = new RemindObject()
|
||||
obj = new()
|
||||
{
|
||||
Time = ts,
|
||||
What = what
|
||||
|
@@ -42,11 +42,11 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
|
||||
_noRedundant = new ConcurrentHashSet<int>(shardRepeaters
|
||||
_noRedundant = new(shardRepeaters
|
||||
.Where(x => x.NoRedundant)
|
||||
.Select(x => x.Id));
|
||||
|
||||
_repeaterQueue = new LinkedList<RunningRepeater>(shardRepeaters
|
||||
_repeaterQueue = new(shardRepeaters
|
||||
.Select(rep => new RunningRepeater(rep))
|
||||
.OrderBy(x => x.NextTime));
|
||||
}
|
||||
@@ -245,7 +245,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
}
|
||||
}
|
||||
|
||||
if (repeater.LastMessageId is ulong lastMessageId)
|
||||
if (repeater.LastMessageId is { } lastMessageId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -318,7 +318,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
||||
await uow.Repeaters
|
||||
.AsQueryable()
|
||||
.Where(x => x.Id == repeaterId)
|
||||
.UpdateAsync(rep => new Repeater()
|
||||
.UpdateAsync(rep => new()
|
||||
{
|
||||
LastMessageId = lastMsgId
|
||||
});
|
||||
|
@@ -26,7 +26,7 @@ public class StreamRoleService : INService
|
||||
|
||||
guildSettings = bot.AllGuildConfigs
|
||||
.ToDictionary(x => x.GuildId, x => x.StreamRole)
|
||||
.Where(x => x.Value != null && x.Value.Enabled)
|
||||
.Where(x => x.Value is { Enabled: true })
|
||||
.ToConcurrent();
|
||||
|
||||
_client.GuildMemberUpdated += Client_GuildMemberUpdated;
|
||||
@@ -197,7 +197,7 @@ public class StreamRoleService : INService
|
||||
|
||||
foreach (var usr in await fromRole.GetMembersAsync().ConfigureAwait(false))
|
||||
{
|
||||
if (usr is IGuildUser x)
|
||||
if (usr is { } x)
|
||||
await RescanUser(x, setting, addRole).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ public class StreamRoleService : INService
|
||||
var users = await guild.GetUsersAsync(CacheMode.CacheOnly).ConfigureAwait(false);
|
||||
foreach (var usr in users.Where(x => x.RoleIds.Contains(setting.FromRoleId) || x.RoleIds.Contains(addRole.Id)))
|
||||
{
|
||||
if (usr is IGuildUser x)
|
||||
if (usr is { } x)
|
||||
await RescanUser(x, setting, addRole).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
@@ -312,6 +312,6 @@ public class StreamRoleService : INService
|
||||
|
||||
private void UpdateCache(ulong guildId, StreamRoleSettings setting)
|
||||
{
|
||||
guildSettings.AddOrUpdate(guildId, (key) => setting, (key, old) => setting);
|
||||
guildSettings.AddOrUpdate(guildId, key => setting, (key, old) => setting);
|
||||
}
|
||||
}
|
@@ -24,7 +24,7 @@ public class VerboseErrorsService : INService
|
||||
|
||||
_ch.CommandErrored += LogVerboseError;
|
||||
|
||||
guildsEnabled = new ConcurrentHashSet<ulong>(bot
|
||||
guildsEnabled = new(bot
|
||||
.AllGuildConfigs
|
||||
.Where(x => x.VerboseErrors)
|
||||
.Select(x => x.GuildId));
|
||||
|
Reference in New Issue
Block a user