From 518f2e425effb4b5dac55b7e7d048f8b34e5c573 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sat, 15 Jun 2024 11:07:17 +0000 Subject: [PATCH] fix: selfhosters shouldn't get a feature limit about reaction roles anymore --- .../Administration/Role/ReactionRolesService.cs | 2 +- .../Modules/Patronage/PatronageService.cs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/Role/ReactionRolesService.cs b/src/NadekoBot/Modules/Administration/Role/ReactionRolesService.cs index f45cf524f..39e476354 100644 --- a/src/NadekoBot/Modules/Administration/Role/ReactionRolesService.cs +++ b/src/NadekoBot/Modules/Administration/Role/ReactionRolesService.cs @@ -254,7 +254,7 @@ public sealed class ReactionRolesService : IReadyExecutor, INService, IReactionR var activeReactionRoles = await ctx.GetTable() .Where(x => x.GuildId == guild.Id) .CountAsync(); - + var limit = await _ps.GetUserLimit(LimitedFeatureName.ReactionRole, guild.OwnerId); if (!_creds.IsOwner(guild.OwnerId) && (activeReactionRoles >= limit.Quota && limit.Quota >= 0)) diff --git a/src/NadekoBot/Modules/Patronage/PatronageService.cs b/src/NadekoBot/Modules/Patronage/PatronageService.cs index 54c427d1e..26449b4d6 100644 --- a/src/NadekoBot/Modules/Patronage/PatronageService.cs +++ b/src/NadekoBot/Modules/Patronage/PatronageService.cs @@ -247,7 +247,7 @@ public sealed class PatronageService { if (_creds.GetCreds().IsOwner(userId)) return true; - + if (!_pConf.Data.IsEnabled) return true; @@ -266,7 +266,7 @@ public sealed class PatronageService { if (_creds.GetCreds().IsOwner(userId)) return true; - + if (!_pConf.Data.IsEnabled) return true; @@ -316,14 +316,23 @@ public sealed class PatronageService private TypedKey CreateKey(LimitedFeatureName key, ulong userId) => new($"limited_feature:{key}:{userId}"); - private QuotaLimit _emptyQuota = new QuotaLimit() + private readonly QuotaLimit _emptyQuota = new QuotaLimit() { Quota = 0, QuotaPeriod = QuotaPer.PerDay, }; + private readonly QuotaLimit _infiniteQuota = new QuotaLimit() + { + Quota = -1, + QuotaPeriod = QuotaPer.PerDay, + }; + public async Task GetUserLimit(LimitedFeatureName name, ulong userId) { + if (!_pConf.Data.IsEnabled) + return _infiniteQuota; + var maybePatron = await GetPatronAsync(userId); if (maybePatron is not { } patron)