Move AutoproxyRoot to CommandTree, add documentation
This commit is contained in:
parent
68b439257d
commit
29d9b91299
@ -20,23 +20,9 @@ namespace PluralKit.Bot
|
||||
_repo = repo;
|
||||
}
|
||||
|
||||
public async Task AutoproxyRoot(Context ctx)
|
||||
public async Task SetAutoproxyMode(Context ctx)
|
||||
{
|
||||
ctx.CheckSystem();
|
||||
|
||||
// check account first
|
||||
// this is ugly, but these global options should be available in DMs
|
||||
if (ctx.Match("account", "ac"))
|
||||
{
|
||||
await AutoproxyAccount(ctx);
|
||||
return;
|
||||
}
|
||||
else if (ctx.Match("timeout", "tm"))
|
||||
{
|
||||
await AutoproxyTimeout(ctx);
|
||||
return;
|
||||
}
|
||||
|
||||
// no need to check account here, it's already done at CommandTree
|
||||
ctx.CheckGuildContext();
|
||||
|
||||
if (ctx.Match("off", "stop", "cancel", "no", "disable", "remove"))
|
||||
@ -143,7 +129,7 @@ namespace PluralKit.Bot
|
||||
return eb.Build();
|
||||
}
|
||||
|
||||
private async Task AutoproxyTimeout(Context ctx)
|
||||
public async Task AutoproxyTimeout(Context ctx)
|
||||
{
|
||||
if (!ctx.HasNext())
|
||||
{
|
||||
@ -172,7 +158,7 @@ namespace PluralKit.Bot
|
||||
await ctx.Reply($"{Emojis.Success} Latch timeout set to {newTimeout} hours.");
|
||||
}
|
||||
|
||||
private async Task AutoproxyAccount(Context ctx)
|
||||
public async Task AutoproxyAccount(Context ctx)
|
||||
{
|
||||
// todo: this might be useful elsewhere, consider moving it to ctx.MatchToggle
|
||||
if (ctx.Match("enable", "on"))
|
||||
|
@ -28,7 +28,9 @@ namespace PluralKit.Bot
|
||||
public static Command SystemFrontPercent = new Command("system frontpercent", "system [system] frontpercent [timespan]", "Shows a system's front breakdown");
|
||||
public static Command SystemPing = new Command("system ping", "system ping <enable|disable>", "Changes your system's ping preferences");
|
||||
public static Command SystemPrivacy = new Command("system privacy", "system privacy <description|members|fronter|fronthistory|all> <public|private>", "Changes your system's privacy settings");
|
||||
public static Command Autoproxy = new Command("autoproxy", "autoproxy [off|front|latch|member]", "Sets your system's autoproxy mode for this server");
|
||||
public static Command AutoproxySet = new Command("autoproxy", "autoproxy [off|front|latch|member]", "Sets your system's autoproxy mode for this server");
|
||||
public static Command AutoproxyTimeout = new Command("autoproxy", "autoproxy timeout [<duration>|off|reset]", "Sets the latch timeout duration for your system");
|
||||
public static Command AutoproxyAccount = new Command("autoproxy", "autoproxy account [on|off]", "Toggles autoproxy globally for the current account");
|
||||
public static Command MemberInfo = new Command("member", "member <member>", "Looks up information about a member");
|
||||
public static Command MemberNew = new Command("member new", "member new <name>", "Creates a new member");
|
||||
public static Command MemberRename = new Command("member rename", "member <member> rename <new name>", "Renames a member");
|
||||
@ -108,6 +110,8 @@ namespace PluralKit.Bot
|
||||
|
||||
public static Command[] SwitchCommands = {Switch, SwitchOut, SwitchMove, SwitchDelete, SwitchDeleteAll};
|
||||
|
||||
public static Command[] AutoproxyCommands = {AutoproxySet, AutoproxyTimeout, AutoproxyAccount};
|
||||
|
||||
public static Command[] LogCommands = {LogChannel, LogChannelClear, LogEnable, LogDisable};
|
||||
|
||||
public static Command[] BlacklistCommands = {BlacklistAdd, BlacklistRemove, BlacklistShow};
|
||||
@ -133,7 +137,7 @@ namespace PluralKit.Bot
|
||||
if (ctx.Match("commands", "cmd", "c"))
|
||||
return CommandHelpRoot(ctx);
|
||||
if (ctx.Match("ap", "autoproxy", "auto"))
|
||||
return ctx.Execute<Autoproxy>(Autoproxy, m => m.AutoproxyRoot(ctx));
|
||||
return HandleAutoproxyCommand(ctx);
|
||||
if (ctx.Match("list", "find", "members", "search", "query", "l", "f", "fd"))
|
||||
return ctx.Execute<SystemList>(SystemList, m => m.MemberList(ctx, ctx.System));
|
||||
if (ctx.Match("link"))
|
||||
@ -457,6 +461,26 @@ namespace PluralKit.Bot
|
||||
}
|
||||
}
|
||||
|
||||
private Task HandleAutoproxyCommand(Context ctx)
|
||||
{
|
||||
// todo: merge this with the changes from #251
|
||||
if (ctx.Match("commands"))
|
||||
return PrintCommandList(ctx, "autoproxy", AutoproxyCommands);
|
||||
|
||||
// ctx.CheckSystem();
|
||||
// oops, that breaks stuff! PKErrors before ctx.Execute don't actually do anything.
|
||||
// so we just emulate checking and throwing an error.
|
||||
if (ctx.System == null)
|
||||
return ctx.Reply($"{Emojis.Error} {Errors.NoSystemError.Message}");
|
||||
|
||||
if (ctx.Match("account", "ac"))
|
||||
return ctx.Execute<Autoproxy>(AutoproxyAccount, m => m.AutoproxyAccount(ctx));
|
||||
else if (ctx.Match("timeout", "tm"))
|
||||
return ctx.Execute<Autoproxy>(AutoproxyTimeout, m => m.AutoproxyTimeout(ctx));
|
||||
else
|
||||
return ctx.Execute<Autoproxy>(AutoproxySet, m => m.SetAutoproxyMode(ctx));
|
||||
}
|
||||
|
||||
private async Task PrintCommandNotFoundError(Context ctx, params Command[] potentialCommands)
|
||||
{
|
||||
var commandListStr = CreatePotentialCommandList(potentialCommands);
|
||||
|
Loading…
Reference in New Issue
Block a user