Migrate more commands to "MatchClear"

This commit is contained in:
Ske 2020-07-08 00:00:23 +02:00
parent 17fbdf553c
commit 1449234a84
3 changed files with 11 additions and 14 deletions

View File

@ -62,11 +62,8 @@ namespace PluralKit.Bot
if (target.System != ctx.System?.Id) throw Errors.NotOwnMemberError;
}
private static bool MatchClear(Context ctx) =>
ctx.Match("clear") || ctx.MatchFlag("c", "clear");
public async Task Description(Context ctx, PKMember target) {
if (MatchClear(ctx))
if (ctx.MatchClear())
{
CheckEditMemberPermission(ctx, target);
@ -109,7 +106,7 @@ namespace PluralKit.Bot
}
public async Task Pronouns(Context ctx, PKMember target) {
if (MatchClear(ctx))
if (ctx.MatchClear())
{
CheckEditMemberPermission(ctx, target);
var patch = new MemberPatch {Pronouns = Partial<string>.Null()};
@ -147,7 +144,7 @@ namespace PluralKit.Bot
public async Task Color(Context ctx, PKMember target)
{
var color = ctx.RemainderOrNull();
if (MatchClear(ctx))
if (ctx.MatchClear())
{
CheckEditMemberPermission(ctx, target);
@ -195,7 +192,7 @@ namespace PluralKit.Bot
}
public async Task Birthday(Context ctx, PKMember target)
{
if (MatchClear(ctx))
if (ctx.MatchClear())
{
CheckEditMemberPermission(ctx, target);
@ -281,7 +278,7 @@ namespace PluralKit.Bot
await ctx.Reply(successStr);
}
if (MatchClear(ctx))
if (ctx.MatchClear())
{
CheckEditMemberPermission(ctx, target);
@ -315,7 +312,7 @@ namespace PluralKit.Bot
{
ctx.CheckGuildContext();
if (MatchClear(ctx))
if (ctx.MatchClear())
{
CheckEditMemberPermission(ctx, target);

View File

@ -45,7 +45,7 @@ namespace PluralKit.Bot
}
// "Sub"command: clear flag
if (ctx.Match("clear", "purge", "clean", "removeall") || ctx.MatchFlag("c", "clear"))
if (ctx.MatchClear())
{
// If we already have multiple tags, this would clear everything, so prompt that
if (target.ProxyTags.Count > 1)

View File

@ -32,7 +32,7 @@ namespace PluralKit.Bot
{
ctx.CheckSystem();
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
if (ctx.MatchClear())
{
var clearPatch = new SystemPatch {Name = null};
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, clearPatch));
@ -63,7 +63,7 @@ namespace PluralKit.Bot
public async Task Description(Context ctx) {
ctx.CheckSystem();
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
if (ctx.MatchClear())
{
var patch = new SystemPatch {Description = null};
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, patch));
@ -101,7 +101,7 @@ namespace PluralKit.Bot
{
ctx.CheckSystem();
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
if (ctx.MatchClear())
{
var patch = new SystemPatch {Tag = null};
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, patch));
@ -226,7 +226,7 @@ namespace PluralKit.Bot
{
if (ctx.System == null) throw Errors.NoSystemError;
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
if (ctx.MatchClear())
{
var clearPatch = new SystemPatch {UiTz = "UTC"};
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, clearPatch));