feat: dynamically show primary command prefix

This commit is contained in:
rladenson 2024-12-31 08:09:18 -07:00 committed by Petal Ladenson
parent 1d50022d6d
commit edfc6714d6
30 changed files with 202 additions and 197 deletions

View file

@ -10,26 +10,26 @@ public partial class CommandTree
{
private async Task PrintCommandNotFoundError(Context ctx, params Command[] potentialCommands)
{
var commandListStr = CreatePotentialCommandList(potentialCommands);
var commandListStr = CreatePotentialCommandList(ctx.DefaultPrefix, potentialCommands);
await ctx.Reply(
$"{Emojis.Error} Unknown command `pk;{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>.");
$"{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(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(params Command[] potentialCommands)
private static string CreatePotentialCommandList(string prefix, params Command[] potentialCommands)
{
return string.Join("\n", potentialCommands.Select(cmd => $"- **pk;{cmd.Usage}** - *{cmd.Description}*"));
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(commands);
var str = CreatePotentialCommandList(ctx.DefaultPrefix, commands);
await ctx.Reply(
$"Here is a list of commands related to {subject}:",
embed: new Embed()