Using pattern matching for nulls where applicable, discarded unused lambda parameters, cleaned up some classes. Unignored ServerLog commands which was mistakenly ignored due to a .gitignore rule

This commit is contained in:
Kwoth
2022-01-01 08:44:51 +01:00
parent f81f9fadd3
commit 9b4eb21321
91 changed files with 1591 additions and 224 deletions

View File

@@ -45,7 +45,7 @@ public partial class Permissions
var localSet = CommandCooldowns.GetOrAdd(channel.Guild.Id, new ConcurrentHashSet<CommandCooldown>());
var toDelete = config.CommandCooldowns.FirstOrDefault(cc => cc.CommandName == name);
if (toDelete != null)
if (toDelete is not null)
uow.Set<CommandCooldown>().Remove(toDelete);
localSet.RemoveWhere(cc => cc.CommandName == name);
if (secs != 0)

View File

@@ -42,7 +42,7 @@ public partial class Permissions : NadekoModule<PermissionService>
[Priority(0)]
public async partial Task PermRole([Leftover] IRole role = null)
{
if (role != null && role == role.Guild.EveryoneRole)
if (role is not null && role == role.Guild.EveryoneRole)
return;
if (role is null)

View File

@@ -38,7 +38,7 @@ public sealed class BlacklistService : IEarlyBehavior
{
foreach (var bl in _blacklist)
{
if (guild != null && bl.Type == BlacklistType.Server && bl.ItemId == guild.Id)
if (guild is not null && bl.Type == BlacklistType.Server && bl.ItemId == guild.Id)
{
Log.Information("Blocked input from blacklisted guild: {GuildName} [{GuildId}]", guild.Name, guild.Id);

View File

@@ -22,10 +22,10 @@ public class CmdCdService : ILateBlocker, INService
var cmdcds = CommandCooldowns.GetOrAdd(guild.Id, new ConcurrentHashSet<CommandCooldown>());
CommandCooldown cdRule;
if ((cdRule = cmdcds.FirstOrDefault(cc => cc.CommandName == commandName)) != null)
if ((cdRule = cmdcds.FirstOrDefault(cc => cc.CommandName == commandName)) is not null)
{
var activeCdsForGuild = ActiveCooldowns.GetOrAdd(guild.Id, new ConcurrentHashSet<ActiveCooldown>());
if (activeCdsForGuild.FirstOrDefault(ac => ac.UserId == user.Id && ac.Command == commandName) != null)
if (activeCdsForGuild.FirstOrDefault(ac => ac.UserId == user.Id && ac.Command == commandName) is not null)
return Task.FromResult(true);
activeCdsForGuild.Add(new() { UserId = user.Id, Command = commandName });

View File

@@ -82,7 +82,7 @@ public class PermissionService : ILateBlocker, INService
PermRole = config.PermissionRole,
Verbose = config.VerbosePermissions
},
(id, old) =>
(_, old) =>
{
old.Permissions = new(config.Permissions);
old.PermRole = config.PermissionRole;