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

@@ -31,10 +31,10 @@ public static class PermissionExtensions
//false = applicable, not allowed
public static bool? CheckPermission(this Permissionv2 perm, IUserMessage message, string commandName, string moduleName)
{
if (!(perm.SecondaryTarget == SecondaryPermissionType.Command &&
perm.SecondaryTargetName.ToLowerInvariant() == commandName.ToLowerInvariant() ||
perm.SecondaryTarget == SecondaryPermissionType.Module &&
perm.SecondaryTargetName.ToLowerInvariant() == moduleName.ToLowerInvariant() ||
if (!((perm.SecondaryTarget == SecondaryPermissionType.Command &&
perm.SecondaryTargetName.ToLowerInvariant() == commandName.ToLowerInvariant()) ||
(perm.SecondaryTarget == SecondaryPermissionType.Module &&
perm.SecondaryTargetName.ToLowerInvariant() == moduleName.ToLowerInvariant()) ||
perm.SecondaryTarget == SecondaryPermissionType.AllModules))
return null;

View File

@@ -5,7 +5,7 @@ namespace NadekoBot.Modules.Permissions.Common;
public class PermissionsCollection<T> : IndexedCollection<T> where T : class, IIndexed
{
private readonly object _localLocker = new object();
private readonly object _localLocker = new();
public PermissionsCollection(IEnumerable<T> source) : base(source)
{
}

View File

@@ -13,7 +13,7 @@ public sealed class BlacklistService : IEarlyBehavior
private IReadOnlyList<BlacklistEntry> _blacklist;
public int Priority => int.MaxValue;
private readonly TypedKey<BlacklistEntry[]> blPubKey = new TypedKey<BlacklistEntry[]>("blacklist.reload");
private readonly TypedKey<BlacklistEntry[]> blPubKey = new("blacklist.reload");
public BlacklistService(DbService db, IPubSub pubSub, IBotCredentials creds)
{
_db = db;

View File

@@ -7,7 +7,7 @@ namespace NadekoBot.Modules.Permissions.Services;
public class CmdCdService : ILateBlocker, INService
{
public ConcurrentDictionary<ulong, ConcurrentHashSet<CommandCooldown>> CommandCooldowns { get; }
public ConcurrentDictionary<ulong, ConcurrentHashSet<ActiveCooldown>> ActiveCooldowns { get; } = new ConcurrentDictionary<ulong, ConcurrentHashSet<ActiveCooldown>>();
public ConcurrentDictionary<ulong, ConcurrentHashSet<ActiveCooldown>> ActiveCooldowns { get; } = new();
public int Priority { get; } = 0;

View File

@@ -113,7 +113,7 @@ public sealed class FilterService : IEarlyBehavior
public async Task<bool> RunBehavior(IGuild guild, IUserMessage msg)
{
if (!(msg.Author is IGuildUser gu) || gu.GuildPermissions.Administrator)
if (msg.Author is not IGuildUser gu || gu.GuildPermissions.Administrator)
return false;
var results = await Task.WhenAll(

View File

@@ -16,8 +16,7 @@ public class PermissionService : ILateBlocker, INService
private readonly IEmbedBuilderService _eb;
//guildid, root permission
public ConcurrentDictionary<ulong, PermissionCache> Cache { get; } =
new ConcurrentDictionary<ulong, PermissionCache>();
public ConcurrentDictionary<ulong, PermissionCache> Cache { get; } = new();
public PermissionService(DiscordSocketClient client,
DbService db,
@@ -135,7 +134,7 @@ public class PermissionService : ILateBlocker, INService
if (moduleName == nameof(Permissions))
{
if (!(user is IGuildUser guildUser))
if (user is not IGuildUser guildUser)
return true;
if (guildUser.GuildPermissions.Administrator)