mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-07 06:17:55 +00:00
feat: premium ID changes
Some checks failed
Build and push Docker image / .net docker build (push) Has been cancelled
.net checks / run .net tests (push) Has been cancelled
.net checks / dotnet-format (push) Has been cancelled
Build and push Rust service Docker images / rust docker build (push) Has been cancelled
rust checks / cargo fmt (push) Has been cancelled
Some checks failed
Build and push Docker image / .net docker build (push) Has been cancelled
.net checks / run .net tests (push) Has been cancelled
.net checks / dotnet-format (push) Has been cancelled
Build and push Rust service Docker images / rust docker build (push) Has been cancelled
rust checks / cargo fmt (push) Has been cancelled
This commit is contained in:
parent
41f8beb2aa
commit
24b6b0d455
16 changed files with 306 additions and 3 deletions
|
|
@ -416,12 +416,15 @@ public class Admin
|
|||
if (target == null)
|
||||
throw new PKError("Unknown system.");
|
||||
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
if (!ctx.HasNext())
|
||||
{
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx.Match("lifetime", "staff"))
|
||||
{
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
if (!await ctx.PromptYesNo($"Grant system `{target.Hid}` lifetime premium?", "Grant"))
|
||||
throw new PKError("Premium entitlement change cancelled.");
|
||||
|
||||
|
|
@ -434,6 +437,7 @@ public class Admin
|
|||
}
|
||||
else if (ctx.Match("none", "clear"))
|
||||
{
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
if (!await ctx.PromptYesNo($"Clear premium entitlements for system `{target.Hid}`?", "Clear"))
|
||||
throw new PKError("Premium entitlement change cancelled.");
|
||||
|
||||
|
|
@ -465,6 +469,7 @@ public class Admin
|
|||
time = result.Value.ToInstant();
|
||||
}
|
||||
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
if (!await ctx.PromptYesNo($"Change premium expiry for system `{target.Hid}` to <t:{time?.ToUnixTimeSeconds()}>?", "Change"))
|
||||
throw new PKError("Premium entitlement change cancelled.");
|
||||
|
||||
|
|
@ -477,6 +482,37 @@ public class Admin
|
|||
}
|
||||
}
|
||||
|
||||
public async Task PremiumIdChangeAllowance(Context ctx)
|
||||
{
|
||||
ctx.AssertBotAdmin();
|
||||
|
||||
var target = await ctx.MatchSystem();
|
||||
if (target == null)
|
||||
throw new PKError("Unknown system.");
|
||||
|
||||
if (!ctx.HasNext())
|
||||
{
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
return;
|
||||
}
|
||||
|
||||
var config = await ctx.Repository.GetSystemConfig(target.Id);
|
||||
var newAllowanceStr = ctx.PopArgument().ToLower().Replace(",", null).Replace("k", "000");
|
||||
if (!int.TryParse(newAllowanceStr, out var newAllowance))
|
||||
throw new PKError($"Couldn't parse `{newAllowanceStr}` as number.");
|
||||
|
||||
await ctx.Reply(null, await CreateEmbed(ctx, target));
|
||||
if (!await ctx.PromptYesNo($"Update premium ID change allowance from **{config.PremiumIdChangesRemaining}** to **{newAllowance}**?", "Update"))
|
||||
throw new PKError("ID change allowance cancelled.");
|
||||
|
||||
await ctx.Repository.UpdateSystemConfig(target.Id, new SystemConfigPatch
|
||||
{
|
||||
PremiumIdChangesRemaining = newAllowance,
|
||||
});
|
||||
|
||||
await ctx.Reply($"{Emojis.Success} Premium entitlement changed.");
|
||||
}
|
||||
|
||||
public async Task AbuseLogCreate(Context ctx)
|
||||
{
|
||||
var denyBotUsage = ctx.MatchFlag("deny", "deny-bot-usage");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue