mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-14 01:30:13 +00:00
implement command root
This commit is contained in:
parent
c1ed7487d7
commit
15ffd16c01
11 changed files with 107 additions and 170 deletions
|
|
@ -1,40 +1,16 @@
|
|||
using Humanizer;
|
||||
|
||||
using Myriad.Types;
|
||||
|
||||
using PluralKit.Core;
|
||||
|
||||
namespace PluralKit.Bot;
|
||||
|
||||
public partial class CommandTree
|
||||
{
|
||||
private async Task PrintCommandNotFoundError(Context ctx, params Command[] potentialCommands)
|
||||
private async Task PrintCommandList(Context ctx, string subject, string commands)
|
||||
{
|
||||
var commandListStr = CreatePotentialCommandList(ctx.DefaultPrefix, potentialCommands);
|
||||
await ctx.Reply(
|
||||
$"{Emojis.Error} Unknown command `{ctx.DefaultPrefix}{ctx.FullCommand().Truncate(100)}`. Perhaps you meant to use one of the following commands?\n{commandListStr}\n\nFor a full list of possible commands, see <https://pluralkit.me/commands>.");
|
||||
}
|
||||
|
||||
private async Task PrintCommandExpectedError(Context ctx, params Command[] potentialCommands)
|
||||
{
|
||||
var commandListStr = CreatePotentialCommandList(ctx.DefaultPrefix, potentialCommands);
|
||||
await ctx.Reply(
|
||||
$"{Emojis.Error} You need to pass a command. Perhaps you meant to use one of the following commands?\n{commandListStr}\n\nFor a full list of possible commands, see <https://pluralkit.me/commands>.");
|
||||
}
|
||||
|
||||
private static string CreatePotentialCommandList(string prefix, params Command[] potentialCommands)
|
||||
{
|
||||
return string.Join("\n", potentialCommands.Select(cmd => $"- **{prefix}{cmd.Usage}** - *{cmd.Description}*"));
|
||||
}
|
||||
|
||||
private async Task PrintCommandList(Context ctx, string subject, params Command[] commands)
|
||||
{
|
||||
var str = CreatePotentialCommandList(ctx.DefaultPrefix, commands);
|
||||
await ctx.Reply(
|
||||
$"Here is a list of commands related to {subject}:",
|
||||
embed: new Embed()
|
||||
{
|
||||
Description = $"{str}\nFor a full list of possible commands, see <https://pluralkit.me/commands>.",
|
||||
Description = $"{commands}\nFor a full list of possible commands, see <https://pluralkit.me/commands>.",
|
||||
Color = DiscordUtils.Blue,
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue