fix: .verbose will now also be respected for expressions

This commit is contained in:
Kwoth
2024-05-18 15:34:16 +00:00
parent 8ac07ce6d7
commit 03fb1a5ca2

View File

@@ -6,6 +6,7 @@ using NadekoBot.Db;
using NadekoBot.Db.Models;
using System.Runtime.CompilerServices;
using LinqToDB.EntityFrameworkCore;
using NadekoBot.Modules.Permissions.Services;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
@@ -77,6 +78,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
private bool ready;
private ConcurrentHashSet<ulong> _disabledGlobalExpressionGuilds;
private readonly PermissionService _pc;
public NadekoExpressionsService(
DbService db,
@@ -87,7 +89,8 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
IPubSub pubSub,
IMessageSenderService sender,
IReplacementService repSvc,
IPermissionChecker permChecker)
IPermissionChecker permChecker,
PermissionService pc)
{
_db = db;
_client = client;
@@ -98,6 +101,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
_sender = sender;
_repSvc = repSvc;
_permChecker = permChecker;
_pc = pc;
_rng = new NadekoRandom();
_pubSub.Sub(_exprsReloadedKey, OnExprsShouldReload);
@@ -138,6 +142,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
var globalItems = uow.Set<NadekoExpression>()
.AsNoTracking()
.Where(x => x.GuildId == null || x.GuildId == 0)
.Where(x => x.Trigger != null)
.AsEnumerable()
.Select(x =>
{
@@ -256,6 +261,9 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
);
if (!result.IsAllowed)
{
var cache = _pc.GetCacheFor(guild.Id);
if (cache.Verbose)
{
if (result.TryPickT3(out var disallowed, out _))
{
@@ -275,6 +283,7 @@ public sealed class NadekoExpressionsService : IExecOnMessage, IReadyExecutor
Log.Information("{PermissionMessage}", permissionMessage);
}
}
return true;
}