Add more lenient prefix parsing

This commit is contained in:
Ske 2019-07-10 10:01:06 +02:00
parent 8dea58437d
commit 9b488d1ab5
2 changed files with 6 additions and 2 deletions

View File

@ -161,8 +161,12 @@ namespace PluralKit.Bot
int argPos = 0; int argPos = 0;
// Check if message starts with the command prefix // Check if message starts with the command prefix
if (arg.HasStringPrefix("pk;", ref argPos) || arg.HasStringPrefix("pk!", ref argPos) || arg.HasMentionPrefix(_client.CurrentUser, ref argPos)) if (arg.HasStringPrefix("pk;", ref argPos, StringComparison.OrdinalIgnoreCase) || arg.HasStringPrefix("pk!", ref argPos, StringComparison.OrdinalIgnoreCase) || arg.HasMentionPrefix(_client.CurrentUser, ref argPos))
{ {
// Essentially move the argPos pointer by however much whitespace is at the start of the post-argPos string
var trimStartLengthDiff = arg.Content.Substring(argPos).Length - arg.Content.Substring(argPos).TrimStart().Length;
argPos += trimStartLengthDiff;
// If it does, fetch the sender's system (because most commands need that) into the context, // If it does, fetch the sender's system (because most commands need that) into the context,
// and start command execution // and start command execution
// Note system may be null if user has no system, hence `OrDefault` // Note system may be null if user has no system, hence `OrDefault`

View File

@ -8,7 +8,7 @@ namespace PluralKit.Bot.Commands
public class HelpCommands: ModuleBase<PKCommandContext> public class HelpCommands: ModuleBase<PKCommandContext>
{ {
[Command] [Command]
public async Task HelpRoot() public async Task HelpRoot([Remainder] string _ignored)
{ {
await Context.Channel.SendMessageAsync(embed: new EmbedBuilder() await Context.Channel.SendMessageAsync(embed: new EmbedBuilder()
.WithTitle("PluralKit") .WithTitle("PluralKit")