From 9b488d1ab5cef82b14a3a8ab0acfbc626e1c3608 Mon Sep 17 00:00:00 2001 From: Ske Date: Wed, 10 Jul 2019 10:01:06 +0200 Subject: [PATCH] Add more lenient prefix parsing --- PluralKit.Bot/Bot.cs | 6 +++++- PluralKit.Bot/Commands/HelpCommands.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/PluralKit.Bot/Bot.cs b/PluralKit.Bot/Bot.cs index eb3cfcb3..3d565c81 100644 --- a/PluralKit.Bot/Bot.cs +++ b/PluralKit.Bot/Bot.cs @@ -161,8 +161,12 @@ namespace PluralKit.Bot int argPos = 0; // 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, // and start command execution // Note system may be null if user has no system, hence `OrDefault` diff --git a/PluralKit.Bot/Commands/HelpCommands.cs b/PluralKit.Bot/Commands/HelpCommands.cs index a4aee6b7..a4c09edb 100644 --- a/PluralKit.Bot/Commands/HelpCommands.cs +++ b/PluralKit.Bot/Commands/HelpCommands.cs @@ -8,7 +8,7 @@ namespace PluralKit.Bot.Commands public class HelpCommands: ModuleBase { [Command] - public async Task HelpRoot() + public async Task HelpRoot([Remainder] string _ignored) { await Context.Channel.SendMessageAsync(embed: new EmbedBuilder() .WithTitle("PluralKit")