Migrate more commands to "MatchClear"
This commit is contained in:
parent
17fbdf553c
commit
1449234a84
@ -62,11 +62,8 @@ namespace PluralKit.Bot
|
|||||||
if (target.System != ctx.System?.Id) throw Errors.NotOwnMemberError;
|
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) {
|
public async Task Description(Context ctx, PKMember target) {
|
||||||
if (MatchClear(ctx))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
CheckEditMemberPermission(ctx, target);
|
CheckEditMemberPermission(ctx, target);
|
||||||
|
|
||||||
@ -109,7 +106,7 @@ namespace PluralKit.Bot
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async Task Pronouns(Context ctx, PKMember target) {
|
public async Task Pronouns(Context ctx, PKMember target) {
|
||||||
if (MatchClear(ctx))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
CheckEditMemberPermission(ctx, target);
|
CheckEditMemberPermission(ctx, target);
|
||||||
var patch = new MemberPatch {Pronouns = Partial<string>.Null()};
|
var patch = new MemberPatch {Pronouns = Partial<string>.Null()};
|
||||||
@ -147,7 +144,7 @@ namespace PluralKit.Bot
|
|||||||
public async Task Color(Context ctx, PKMember target)
|
public async Task Color(Context ctx, PKMember target)
|
||||||
{
|
{
|
||||||
var color = ctx.RemainderOrNull();
|
var color = ctx.RemainderOrNull();
|
||||||
if (MatchClear(ctx))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
CheckEditMemberPermission(ctx, target);
|
CheckEditMemberPermission(ctx, target);
|
||||||
|
|
||||||
@ -195,7 +192,7 @@ namespace PluralKit.Bot
|
|||||||
}
|
}
|
||||||
public async Task Birthday(Context ctx, PKMember target)
|
public async Task Birthday(Context ctx, PKMember target)
|
||||||
{
|
{
|
||||||
if (MatchClear(ctx))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
CheckEditMemberPermission(ctx, target);
|
CheckEditMemberPermission(ctx, target);
|
||||||
|
|
||||||
@ -281,7 +278,7 @@ namespace PluralKit.Bot
|
|||||||
await ctx.Reply(successStr);
|
await ctx.Reply(successStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MatchClear(ctx))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
CheckEditMemberPermission(ctx, target);
|
CheckEditMemberPermission(ctx, target);
|
||||||
|
|
||||||
@ -315,7 +312,7 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
ctx.CheckGuildContext();
|
ctx.CheckGuildContext();
|
||||||
|
|
||||||
if (MatchClear(ctx))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
CheckEditMemberPermission(ctx, target);
|
CheckEditMemberPermission(ctx, target);
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ namespace PluralKit.Bot
|
|||||||
}
|
}
|
||||||
|
|
||||||
// "Sub"command: clear flag
|
// "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 we already have multiple tags, this would clear everything, so prompt that
|
||||||
if (target.ProxyTags.Count > 1)
|
if (target.ProxyTags.Count > 1)
|
||||||
|
@ -32,7 +32,7 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
ctx.CheckSystem();
|
ctx.CheckSystem();
|
||||||
|
|
||||||
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
var clearPatch = new SystemPatch {Name = null};
|
var clearPatch = new SystemPatch {Name = null};
|
||||||
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, clearPatch));
|
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, clearPatch));
|
||||||
@ -63,7 +63,7 @@ namespace PluralKit.Bot
|
|||||||
public async Task Description(Context ctx) {
|
public async Task Description(Context ctx) {
|
||||||
ctx.CheckSystem();
|
ctx.CheckSystem();
|
||||||
|
|
||||||
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
var patch = new SystemPatch {Description = null};
|
var patch = new SystemPatch {Description = null};
|
||||||
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, patch));
|
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, patch));
|
||||||
@ -101,7 +101,7 @@ namespace PluralKit.Bot
|
|||||||
{
|
{
|
||||||
ctx.CheckSystem();
|
ctx.CheckSystem();
|
||||||
|
|
||||||
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
var patch = new SystemPatch {Tag = null};
|
var patch = new SystemPatch {Tag = null};
|
||||||
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, patch));
|
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.System == null) throw Errors.NoSystemError;
|
||||||
|
|
||||||
if (ctx.MatchFlag("c", "clear") || ctx.Match("clear"))
|
if (ctx.MatchClear())
|
||||||
{
|
{
|
||||||
var clearPatch = new SystemPatch {UiTz = "UTC"};
|
var clearPatch = new SystemPatch {UiTz = "UTC"};
|
||||||
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, clearPatch));
|
await _db.Execute(conn => conn.UpdateSystem(ctx.System.Id, clearPatch));
|
||||||
|
Loading…
Reference in New Issue
Block a user