Improve in-bot command documentation
Adds command descriptions, changes formatting on command listings, and adds more direct command listing commands.
This commit is contained in:
		| @@ -9,47 +9,57 @@ namespace PluralKit.Bot.Commands | ||||
| { | ||||
|     public class CommandTree | ||||
|     { | ||||
|         public static Command SystemInfo = new Command("system", "system [system]", "uwu"); | ||||
|         public static Command SystemNew = new Command("system new", "system new [name]", "uwu"); | ||||
|         public static Command SystemRename = new Command("system name", "system rename [name]", "uwu"); | ||||
|         public static Command SystemDesc = new Command("system description", "system description [description]", "uwu"); | ||||
|         public static Command SystemTag = new Command("system tag", "system tag [tag]", "uwu"); | ||||
|         public static Command SystemAvatar = new Command("system avatar", "system avatar [url|@mention]", "uwu"); | ||||
|         public static Command SystemDelete = new Command("system delete", "system delete", "uwu"); | ||||
|         public static Command SystemTimezone = new Command("system timezone", "system timezone [timezone]", "uwu"); | ||||
|         public static Command SystemList = new Command("system list", "system list [full]", "uwu"); | ||||
|         public static Command SystemFronter = new Command("system fronter", "system fronter", "uwu"); | ||||
|         public static Command SystemFrontHistory = new Command("system fronthistory", "system fronthistory", "uwu"); | ||||
|         public static Command SystemFrontPercent = new Command("system frontpercent", "system frontpercent [timespan]", "uwu"); | ||||
|         public static Command MemberInfo = new Command("member", "member <member>", "uwu"); | ||||
|         public static Command MemberNew = new Command("member new", "member new <name>", "uwu"); | ||||
|         public static Command MemberRename = new Command("member rename", "member <member> rename <new name>", "uwu"); | ||||
|         public static Command MemberDesc = new Command("member description", "member <member> description [description]", "uwu"); | ||||
|         public static Command MemberPronouns = new Command("member pronouns", "member <member> pronouns [pronouns]", "uwu"); | ||||
|         public static Command MemberColor = new Command("member color", "member <member> color [color]", "uwu"); | ||||
|         public static Command MemberBirthday = new Command("member birthday", "member <member> birthday [birthday]", "uwu"); | ||||
|         public static Command MemberProxy = new Command("member proxy", "member <member> proxy [add|remove] [example proxy]", "uwu"); | ||||
|         public static Command MemberDelete = new Command("member delete", "member <member> delete", "uwu"); | ||||
|         public static Command MemberAvatar = new Command("member avatar", "member <member> avatar [url|@mention]", "uwu"); | ||||
|         public static Command MemberDisplayName = new Command("member displayname", "member <member> displayname [display name]", "uwu"); | ||||
|         public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "uwu"); | ||||
|         public static Command Switch = new Command("switch", "switch <member> [member 2] [member 3...]", "uwu"); | ||||
|         public static Command SwitchOut = new Command("switch out", "switch out", "uwu"); | ||||
|         public static Command SwitchMove = new Command("switch move", "switch move <date/time>", "uwu"); | ||||
|         public static Command SwitchDelete = new Command("switch delete", "switch delete", "uwu"); | ||||
|         public static Command Link = new Command("link", "link <account>", "uwu"); | ||||
|         public static Command Unlink = new Command("unlink", "unlink [account]", "uwu"); | ||||
|         public static Command TokenGet = new Command("token", "token", "uwu"); | ||||
|         public static Command TokenRefresh = new Command("token refresh", "token refresh", "uwu"); | ||||
|         public static Command Import = new Command("import", "import [fileurl]", "uwu"); | ||||
|         public static Command Export = new Command("export", "export", "uwu"); | ||||
|         public static Command HelpCommandList = new Command("commands", "commands", "uwu"); | ||||
|         public static Command HelpProxy = new Command("help proxy", "help proxy", "uwu"); | ||||
|         public static Command Help = new Command("help", "help", "uwu"); | ||||
|         public static Command Message = new Command("message", "message <id|link>", "uwu"); | ||||
|         public static Command Log = new Command("log", "log <channel>", "uwu"); | ||||
|         public static Command Invite = new Command("invite", "invite", "uwu"); | ||||
|         public static Command PermCheck = new Command("permcheck", "permcheck <guild>", "uwu"); | ||||
|         public static Command SystemInfo = new Command("system", "system [system]", "Looks up information about a system"); | ||||
|         public static Command SystemNew = new Command("system new", "system new [name]", "Creates a new system"); | ||||
|         public static Command SystemRename = new Command("system name", "system rename [name]", "Renames your system"); | ||||
|         public static Command SystemDesc = new Command("system description", "system description [description]", "Changes your system's description"); | ||||
|         public static Command SystemTag = new Command("system tag", "system tag [tag]", "Changes your system's tag"); | ||||
|         public static Command SystemAvatar = new Command("system avatar", "system avatar [url|@mention]", "Changes your system's avatar"); | ||||
|         public static Command SystemDelete = new Command("system delete", "system delete", "Deletes your system"); | ||||
|         public static Command SystemTimezone = new Command("system timezone", "system timezone [timezone]", "Changes your system's time zone"); | ||||
|         public static Command SystemList = new Command("system list", "system [system] list [full]", "Lists a system's members"); | ||||
|         public static Command SystemFronter = new Command("system fronter", "system [system] fronter", "Shows a system's fronter(s)"); | ||||
|         public static Command SystemFrontHistory = new Command("system fronthistory", "system [system] fronthistory", "Shows a system's front history"); | ||||
|         public static Command SystemFrontPercent = new Command("system frontpercent", "system [system] frontpercent [timespan]", "Shows a system's front breakdown"); | ||||
|         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"); | ||||
|         public static Command MemberDesc = new Command("member description", "member <member> description [description]", "Changes a member's description"); | ||||
|         public static Command MemberPronouns = new Command("member pronouns", "member <member> pronouns [pronouns]", "Changes a member's pronouns"); | ||||
|         public static Command MemberColor = new Command("member color", "member <member> color [color]", "Changes a member's color"); | ||||
|         public static Command MemberBirthday = new Command("member birthday", "member <member> birthday [birthday]", "Changes a member's birthday"); | ||||
|         public static Command MemberProxy = new Command("member proxy", "member <member> proxy [add|remove] [example proxy]", "Changes, adds, or removes a member's proxy tags"); | ||||
|         public static Command MemberDelete = new Command("member delete", "member <member> delete", "Deletes a member"); | ||||
|         public static Command MemberAvatar = new Command("member avatar", "member <member> avatar [url|@mention]", "Changes a member's avatar"); | ||||
|         public static Command MemberDisplayName = new Command("member displayname", "member <member> displayname [display name]", "Changes a member's display name"); | ||||
|         public static Command MemberKeepProxy = new Command("member keepproxy", "member <member> keepproxy [on|off]", "Sets whether to include a member's proxy tags when proxying"); | ||||
|         public static Command Switch = new Command("switch", "switch <member> [member 2] [member 3...]", "Registers a switch"); | ||||
|         public static Command SwitchOut = new Command("switch out", "switch out", "Registers a switch with no members"); | ||||
|         public static Command SwitchMove = new Command("switch move", "switch move <date/time>", "Moves the latest switch in time"); | ||||
|         public static Command SwitchDelete = new Command("switch delete", "switch delete [all]", "Deletes the latest switch (or them all)"); | ||||
|         public static Command Link = new Command("link", "link <account>", "Links your system to another account"); | ||||
|         public static Command Unlink = new Command("unlink", "unlink [account]", "Unlinks your system from an account"); | ||||
|         public static Command TokenGet = new Command("token", "token", "Gets your system's API token"); | ||||
|         public static Command TokenRefresh = new Command("token refresh", "token refresh", "Resets your system's API token"); | ||||
|         public static Command Import = new Command("import", "import [fileurl]", "Imports system information from a data file"); | ||||
|         public static Command Export = new Command("export", "export", "Exports system information to a data file"); | ||||
|         public static Command Help = new Command("help", "help", "Shows help information about PluralKit"); | ||||
|         public static Command Message = new Command("message", "message <id|link>", "Looks up a proxied message"); | ||||
|         public static Command Log = new Command("log", "log <channel>", "Designates a channel to post proxied messages to"); | ||||
|         public static Command Invite = new Command("invite", "invite", "Gets a link to invite PluralKit to other servers"); | ||||
|         public static Command PermCheck = new Command("permcheck", "permcheck <guild>", "Checks whether a server's permission setup is correct"); | ||||
|  | ||||
|         public static Command[] SystemCommands = { | ||||
|             SystemInfo, SystemNew, SystemRename, SystemTag, SystemDesc, SystemAvatar, SystemDelete, SystemTimezone, | ||||
|             SystemList, SystemFronter, SystemFrontHistory, SystemFrontPercent | ||||
|         }; | ||||
|  | ||||
|         public static Command[] MemberCommands = { | ||||
|             MemberInfo, MemberNew, MemberRename, MemberDisplayName, MemberDesc, MemberPronouns, MemberColor, | ||||
|             MemberBirthday, MemberProxy, MemberKeepProxy, MemberDelete, MemberAvatar, | ||||
|         }; | ||||
|  | ||||
|         public static Command[] SwitchCommands = {Switch, SwitchOut, SwitchMove, SwitchDelete}; | ||||
|          | ||||
|         private IDiscordClient _client; | ||||
|  | ||||
| @@ -81,12 +91,12 @@ namespace PluralKit.Bot.Commands | ||||
|                 return ctx.Execute<ImportExportCommands>(Export, m => m.Export(ctx)); | ||||
|             if (ctx.Match("help")) | ||||
|                 if (ctx.Match("commands")) | ||||
|                     return ctx.Execute<HelpCommands>(HelpCommandList, m => m.CommandList(ctx)); | ||||
|                     return ctx.Reply("For the list of commands, see the website: <https://pluralkit.me/commands>"); | ||||
|                 else if (ctx.Match("proxy")) | ||||
|                     return ctx.Execute<HelpCommands>(HelpProxy, m => m.HelpProxy(ctx)); | ||||
|                     return ctx.Reply("The proxy help page has been moved! See the website: https://pluralkit.me/guide#proxying"); | ||||
|                 else return ctx.Execute<HelpCommands>(Help, m => m.HelpRoot(ctx)); | ||||
|             if (ctx.Match("commands")) | ||||
|                 return ctx.Execute<HelpCommands>(HelpCommandList, m => m.CommandList(ctx)); | ||||
|                 return ctx.Reply("For the list of commands, see the website: <https://pluralkit.me/commands>"); | ||||
|             if (ctx.Match("message", "msg")) | ||||
|                 return ctx.Execute<ModCommands>(Message, m => m.GetMessage(ctx)); | ||||
|             if (ctx.Match("log")) | ||||
| @@ -148,6 +158,8 @@ namespace PluralKit.Bot.Commands | ||||
|                 await ctx.Execute<SystemCommands>(SystemFrontHistory, m => m.SystemFrontHistory(ctx, ctx.System)); | ||||
|             else if (ctx.Match("fp", "frontpercent", "front%", "frontbreakdown")) | ||||
|                 await ctx.Execute<SystemCommands>(SystemFrontPercent, m => m.SystemFrontPercent(ctx, ctx.System)); | ||||
|             else if (ctx.Match("commands", "help")) | ||||
|                 await PrintCommandList(ctx, "systems", SystemCommands); | ||||
|             else if (!ctx.HasNext()) // Bare command | ||||
|                 await ctx.Execute<SystemCommands>(SystemInfo, m => m.Query(ctx, ctx.System)); | ||||
|             else | ||||
| @@ -197,6 +209,8 @@ namespace PluralKit.Bot.Commands | ||||
|         { | ||||
|             if (ctx.Match("new", "n", "add", "create", "register")) | ||||
|                 await ctx.Execute<MemberCommands>(MemberNew, m => m.NewMember(ctx)); | ||||
|             else if (ctx.Match("commands", "help")) | ||||
|                 await PrintCommandList(ctx, "members", MemberCommands); | ||||
|             else if (await ctx.MatchMember() is PKMember target) | ||||
|                 await HandleMemberCommandTargeted(ctx, target); | ||||
|             else if (!ctx.HasNext()) | ||||
| @@ -243,6 +257,8 @@ namespace PluralKit.Bot.Commands | ||||
|                 await ctx.Execute<SwitchCommands>(SwitchMove, m => m.SwitchMove(ctx)); | ||||
|             else if (ctx.Match("delete", "remove", "erase", "cancel", "yeet")) | ||||
|                 await ctx.Execute<SwitchCommands>(SwitchDelete, m => m.SwitchDelete(ctx)); | ||||
|             else if (ctx.Match("commands", "help")) | ||||
|                 await PrintCommandList(ctx, "switching", SwitchCommands); | ||||
|             else if (ctx.HasNext()) // there are following arguments | ||||
|                 await ctx.Execute<SwitchCommands>(Switch, m => m.Switch(ctx)); | ||||
|             else | ||||
| @@ -265,7 +281,13 @@ namespace PluralKit.Bot.Commands | ||||
|          | ||||
|         private static string CreatePotentialCommandList(params Command[] potentialCommands) | ||||
|         { | ||||
|             return string.Join("\n", potentialCommands.Select(cmd => $"- `pk;{cmd.Usage}`")); | ||||
|             return string.Join("\n", potentialCommands.Select(cmd => $"- **pk;{cmd.Usage}** - *{cmd.Description}*")); | ||||
|         } | ||||
|  | ||||
|         private async Task PrintCommandList(Context ctx, string subject, params Command[] commands) | ||||
|         { | ||||
|             var str = CreatePotentialCommandList(commands); | ||||
|             await ctx.Reply($"Here is a list of commands related to {subject}: \n{str}\nFor a full list of possible commands, see <https://pluralkit.me/commands>."); | ||||
|         } | ||||
|  | ||||
|         private async Task<string> CreateSystemNotFoundError(Context ctx) | ||||
|   | ||||
| @@ -7,18 +7,6 @@ namespace PluralKit.Bot.Commands | ||||
| { | ||||
|     public class HelpCommands | ||||
|     { | ||||
|     public async Task HelpProxy(Context ctx) | ||||
|         { | ||||
|             await ctx.Reply( | ||||
|                 "The proxy help page has been moved! See the website: https://pluralkit.me/guide#proxying"); | ||||
|         } | ||||
|          | ||||
|         public async Task HelpMember(Context ctx) | ||||
|         { | ||||
|             await ctx.Reply( | ||||
|                 "The member help page has been moved! See the website: https://pluralkit.me/guide#member-management"); | ||||
|         } | ||||
|          | ||||
|         public async Task HelpRoot(Context ctx) | ||||
|         { | ||||
|             await ctx.Reply(embed: new EmbedBuilder() | ||||
| @@ -34,11 +22,5 @@ namespace PluralKit.Bot.Commands | ||||
|                 .WithColor(Color.Blue) | ||||
|                 .Build()); | ||||
|         } | ||||
|          | ||||
|         public async Task CommandList(Context ctx) | ||||
|         { | ||||
|             await ctx.Reply( | ||||
|                 "The command list has been moved! See the website: https://pluralkit.me/commands"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user