feat: move a couple of commands to MatchToggle
This commit is contained in:
		@@ -534,21 +534,7 @@ public class MemberEdit
 | 
				
			|||||||
        if (ctx.System == null) throw Errors.NoSystemError;
 | 
					        if (ctx.System == null) throw Errors.NoSystemError;
 | 
				
			||||||
        if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError;
 | 
					        if (target.System != ctx.System.Id) throw Errors.NotOwnMemberError;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool newValue;
 | 
					        if (!ctx.HasNext())
 | 
				
			||||||
        // todo: MatchToggle
 | 
					 | 
				
			||||||
        if (ctx.Match("on", "enabled", "true", "yes") || ctx.MatchFlag("on", "enabled", "true", "yes"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            newValue = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else if (ctx.Match("off", "disabled", "false", "no") || ctx.MatchFlag("off", "disabled", "false", "no"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            newValue = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else if (ctx.HasNext())
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            throw new PKSyntaxError("You must pass either \"on\" or \"off\".");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (target.AllowAutoproxy)
 | 
					            if (target.AllowAutoproxy)
 | 
				
			||||||
                await ctx.Reply(
 | 
					                await ctx.Reply(
 | 
				
			||||||
@@ -559,7 +545,7 @@ public class MemberEdit
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ;
 | 
					        var newValue = ctx.MatchToggle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        var patch = new MemberPatch { AllowAutoproxy = Partial<bool>.Present(newValue) };
 | 
					        var patch = new MemberPatch { AllowAutoproxy = Partial<bool>.Present(newValue) };
 | 
				
			||||||
        await _repo.UpdateMember(target.Id, patch);
 | 
					        await _repo.UpdateMember(target.Id, patch);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -497,21 +497,7 @@ public class SystemEdit
 | 
				
			|||||||
        else
 | 
					        else
 | 
				
			||||||
            serverText = $"the server {guild.Name.EscapeMarkdown()}";
 | 
					            serverText = $"the server {guild.Name.EscapeMarkdown()}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        bool newValue;
 | 
					        if (!ctx.HasNext())
 | 
				
			||||||
        // todo: MatchToggle
 | 
					 | 
				
			||||||
        if (ctx.Match("on", "enabled", "true", "yes"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            newValue = true;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else if (ctx.Match("off", "disabled", "false", "no"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            newValue = false;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else if (ctx.HasNext())
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            throw new PKSyntaxError("You must pass either \"on\" or \"off\".");
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (gs.ProxyEnabled)
 | 
					            if (gs.ProxyEnabled)
 | 
				
			||||||
                await ctx.Reply(
 | 
					                await ctx.Reply(
 | 
				
			||||||
@@ -522,6 +508,8 @@ public class SystemEdit
 | 
				
			|||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        var newValue = ctx.MatchToggle();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        await _repo.UpdateSystemGuild(ctx.System.Id, guild.Id, new SystemGuildPatch { ProxyEnabled = newValue });
 | 
					        await _repo.UpdateSystemGuild(ctx.System.Id, guild.Id, new SystemGuildPatch { ProxyEnabled = newValue });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (newValue)
 | 
					        if (newValue)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user