2021-12-07 01:36:54 -05:00
using Humanizer ;
2022-10-27 04:52:29 +02:00
using Myriad.Types ;
2021-12-07 01:36:54 -05:00
using PluralKit.Core ;
namespace PluralKit.Bot ;
public partial class CommandTree
{
private async Task PrintCommandNotFoundError ( Context ctx , params Command [ ] potentialCommands )
{
2024-12-31 08:09:18 -07:00
var commandListStr = CreatePotentialCommandList ( ctx . DefaultPrefix , potentialCommands ) ;
2021-12-07 01:36:54 -05:00
await ctx . Reply (
2024-12-31 08:09:18 -07:00
$"{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>." ) ;
2021-12-07 01:36:54 -05:00
}
2022-03-30 04:36:22 -04:00
2021-12-07 01:36:54 -05:00
private async Task PrintCommandExpectedError ( Context ctx , params Command [ ] potentialCommands )
{
2024-12-31 08:09:18 -07:00
var commandListStr = CreatePotentialCommandList ( ctx . DefaultPrefix , potentialCommands ) ;
2021-12-07 01:36:54 -05:00
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>." ) ;
}
2024-12-31 08:09:18 -07:00
private static string CreatePotentialCommandList ( string prefix , params Command [ ] potentialCommands )
2021-12-07 01:36:54 -05:00
{
2024-12-31 08:09:18 -07:00
return string . Join ( "\n" , potentialCommands . Select ( cmd = > $"- **{prefix}{cmd.Usage}** - *{cmd.Description}*" ) ) ;
2021-12-07 01:36:54 -05:00
}
private async Task PrintCommandList ( Context ctx , string subject , params Command [ ] commands )
{
2024-12-31 08:09:18 -07:00
var str = CreatePotentialCommandList ( ctx . DefaultPrefix , commands ) ;
2022-10-27 04:52:29 +02:00
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>." ,
Color = DiscordUtils . Blue ,
}
) ;
2021-12-07 01:36:54 -05:00
}
private async Task < string > CreateSystemNotFoundError ( Context ctx )
{
var input = ctx . PopArgument ( ) ;
if ( input . TryParseMention ( out var id ) )
{
// Try to resolve the user ID to find the associated account,
// so we can print their username.
var user = await ctx . Rest . GetUser ( id ) ;
if ( user ! = null )
return $"Account **{user.Username}#{user.Discriminator}** does not have a system registered." ;
return $"Account with ID `{id}` not found." ;
}
return $"System with ID {input.AsCode()} not found." ;
}
}