mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-10 17:28:27 -04:00
fix: selfhosters shouldn't get a feature limit about reaction roles anymore
This commit is contained in:
@@ -254,7 +254,7 @@ public sealed class ReactionRolesService : IReadyExecutor, INService, IReactionR
|
|||||||
var activeReactionRoles = await ctx.GetTable<ReactionRoleV2>()
|
var activeReactionRoles = await ctx.GetTable<ReactionRoleV2>()
|
||||||
.Where(x => x.GuildId == guild.Id)
|
.Where(x => x.GuildId == guild.Id)
|
||||||
.CountAsync();
|
.CountAsync();
|
||||||
|
|
||||||
var limit = await _ps.GetUserLimit(LimitedFeatureName.ReactionRole, guild.OwnerId);
|
var limit = await _ps.GetUserLimit(LimitedFeatureName.ReactionRole, guild.OwnerId);
|
||||||
|
|
||||||
if (!_creds.IsOwner(guild.OwnerId) && (activeReactionRoles >= limit.Quota && limit.Quota >= 0))
|
if (!_creds.IsOwner(guild.OwnerId) && (activeReactionRoles >= limit.Quota && limit.Quota >= 0))
|
||||||
|
@@ -247,7 +247,7 @@ public sealed class PatronageService
|
|||||||
{
|
{
|
||||||
if (_creds.GetCreds().IsOwner(userId))
|
if (_creds.GetCreds().IsOwner(userId))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!_pConf.Data.IsEnabled)
|
if (!_pConf.Data.IsEnabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ public sealed class PatronageService
|
|||||||
{
|
{
|
||||||
if (_creds.GetCreds().IsOwner(userId))
|
if (_creds.GetCreds().IsOwner(userId))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!_pConf.Data.IsEnabled)
|
if (!_pConf.Data.IsEnabled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -316,14 +316,23 @@ public sealed class PatronageService
|
|||||||
private TypedKey<int> CreateKey(LimitedFeatureName key, ulong userId)
|
private TypedKey<int> CreateKey(LimitedFeatureName key, ulong userId)
|
||||||
=> new($"limited_feature:{key}:{userId}");
|
=> new($"limited_feature:{key}:{userId}");
|
||||||
|
|
||||||
private QuotaLimit _emptyQuota = new QuotaLimit()
|
private readonly QuotaLimit _emptyQuota = new QuotaLimit()
|
||||||
{
|
{
|
||||||
Quota = 0,
|
Quota = 0,
|
||||||
QuotaPeriod = QuotaPer.PerDay,
|
QuotaPeriod = QuotaPer.PerDay,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private readonly QuotaLimit _infiniteQuota = new QuotaLimit()
|
||||||
|
{
|
||||||
|
Quota = -1,
|
||||||
|
QuotaPeriod = QuotaPer.PerDay,
|
||||||
|
};
|
||||||
|
|
||||||
public async Task<QuotaLimit> GetUserLimit(LimitedFeatureName name, ulong userId)
|
public async Task<QuotaLimit> GetUserLimit(LimitedFeatureName name, ulong userId)
|
||||||
{
|
{
|
||||||
|
if (!_pConf.Data.IsEnabled)
|
||||||
|
return _infiniteQuota;
|
||||||
|
|
||||||
var maybePatron = await GetPatronAsync(userId);
|
var maybePatron = await GetPatronAsync(userId);
|
||||||
|
|
||||||
if (maybePatron is not { } patron)
|
if (maybePatron is not { } patron)
|
||||||
|
Reference in New Issue
Block a user