Confirm before clearing (most) entity properties
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -86,7 +86,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public async Task GroupDisplayName(Context ctx, PKGroup target)
|
||||
{
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this group's display name"))
|
||||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace PluralKit.Bot
|
||||
|
||||
public async Task GroupDescription(Context ctx, PKGroup target)
|
||||
{
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this group's description"))
|
||||
{
|
||||
ctx.CheckOwnGroup(target);
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace PluralKit.Bot
|
||||
throw new PKSyntaxError("This group does not have an icon set. Set one by attaching an image to this command, or by passing an image URL or @mention.");
|
||||
}
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this group's icon"))
|
||||
await ClearIcon();
|
||||
else if (await ctx.MatchImage() is {} img)
|
||||
await SetIcon(img);
|
||||
|
@@ -85,7 +85,7 @@ namespace PluralKit.Bot
|
||||
private async Task AvatarCommandTree(AvatarLocation location, Context ctx, PKMember target, MemberGuildSettings? guildData)
|
||||
{
|
||||
// First, see if we need to *clear*
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this member's avatar"))
|
||||
{
|
||||
ctx.CheckSystem().CheckOwnMember(target);
|
||||
await AvatarClear(location, ctx, target, guildData);
|
||||
|
@@ -64,7 +64,7 @@ namespace PluralKit.Bot
|
||||
}
|
||||
|
||||
public async Task Description(Context ctx, PKMember target) {
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this member's description"))
|
||||
{
|
||||
CheckEditMemberPermission(ctx, target);
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace PluralKit.Bot
|
||||
}
|
||||
|
||||
public async Task Pronouns(Context ctx, PKMember target) {
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this member's pronouns"))
|
||||
{
|
||||
CheckEditMemberPermission(ctx, target);
|
||||
var patch = new MemberPatch {Pronouns = Partial<string>.Null()};
|
||||
@@ -145,7 +145,7 @@ namespace PluralKit.Bot
|
||||
public async Task Color(Context ctx, PKMember target)
|
||||
{
|
||||
var color = ctx.RemainderOrNull();
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear())
|
||||
{
|
||||
CheckEditMemberPermission(ctx, target);
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace PluralKit.Bot
|
||||
}
|
||||
public async Task Birthday(Context ctx, PKMember target)
|
||||
{
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this member's birthday"))
|
||||
{
|
||||
CheckEditMemberPermission(ctx, target);
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace PluralKit.Bot
|
||||
await ctx.Reply(successStr);
|
||||
}
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this member's display name"))
|
||||
{
|
||||
CheckEditMemberPermission(ctx, target);
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace PluralKit.Bot
|
||||
{
|
||||
ctx.CheckGuildContext();
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("this member's server name"))
|
||||
{
|
||||
CheckEditMemberPermission(ctx, target);
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Dapper;
|
||||
@@ -46,7 +46,7 @@ namespace PluralKit.Bot
|
||||
}
|
||||
|
||||
// "Sub"command: clear flag
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear())
|
||||
{
|
||||
// If we already have multiple tags, this would clear everything, so prompt that
|
||||
if (target.ProxyTags.Count > 1)
|
||||
|
@@ -32,7 +32,7 @@ namespace PluralKit.Bot
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("your system's name"))
|
||||
{
|
||||
var clearPatch = new SystemPatch {Name = null};
|
||||
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id, clearPatch));
|
||||
@@ -63,7 +63,7 @@ namespace PluralKit.Bot
|
||||
public async Task Description(Context ctx) {
|
||||
ctx.CheckSystem();
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("your system's description"))
|
||||
{
|
||||
var patch = new SystemPatch {Description = null};
|
||||
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id, patch));
|
||||
@@ -101,7 +101,7 @@ namespace PluralKit.Bot
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("your system's tag"))
|
||||
{
|
||||
var patch = new SystemPatch {Tag = null};
|
||||
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id, patch));
|
||||
@@ -175,7 +175,7 @@ namespace PluralKit.Bot
|
||||
throw new PKSyntaxError("This system does not have an icon set. Set one by attaching an image to this command, or by passing an image URL or @mention.");
|
||||
}
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear("your system's icon"))
|
||||
await ClearIcon();
|
||||
else if (await ctx.MatchImage() is {} img)
|
||||
await SetIcon(img);
|
||||
@@ -226,7 +226,7 @@ namespace PluralKit.Bot
|
||||
{
|
||||
if (ctx.System == null) throw Errors.NoSystemError;
|
||||
|
||||
if (ctx.MatchClear())
|
||||
if (await ctx.MatchClear())
|
||||
{
|
||||
var clearPatch = new SystemPatch {UiTz = "UTC"};
|
||||
await _db.Execute(conn => _repo.UpdateSystem(conn, ctx.System.Id, clearPatch));
|
||||
|
Reference in New Issue
Block a user