mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
Kotz's editorconfig styles slightly modified. Target typed new usage. Brackets in expressions used for clarity.
This commit is contained in:
@@ -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;
|
||||
|
||||
|
@@ -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)
|
||||
{
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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(
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user