diff --git a/src/Discord.Net.Commands/CommandParser.cs b/src/Discord.Net.Commands/CommandParser.cs index b9408f963..2e055802f 100644 --- a/src/Discord.Net.Commands/CommandParser.cs +++ b/src/Discord.Net.Commands/CommandParser.cs @@ -14,33 +14,7 @@ namespace Discord.Commands Parameter, QuotedParameter } - - private static bool isOpenQuote(Dictionary map, char c) - { - // determine if the map contains the key for this value - if(map != null) - { - return map.ContainsKey(c); - } - // or if the value is a normal quote " - return c == '\"'; - } - - // get the corresponding matching quote for the key - private static char getMatch(Dictionary map, char c) - { - if (map != null) - { - char value; - if( map.TryGetValue(c, out value)) - { - return value; - } - } - - return '\"'; - } - + public static async Task ParseArgsAsync(CommandInfo command, ICommandContext context, bool ignoreExtraArgs, IServiceProvider services, string input, int startPos) { ParameterInfo curParam = null; @@ -53,6 +27,31 @@ namespace Discord.Commands bool isEscaping = false; char c, matchQuote = '\0'; + // local helper functions + bool IsOpenQuote(IReadOnlyDictionary dict, char ch) + { + // return if the key is contained in the dictionary if it exists + if (dict != null) + return dict.ContainsKey(ch); + // or otherwise if it is the default double quote + return c == '\"'; + } + + char GetMatch(IReadOnlyDictionary dict, char ch) + { + // get the corresponding value for the key, if it exists + if (dict != null) + { + char value; + if (dict.TryGetValue(c, out value)) + { + return value; + } + } + // or get the default pair of the default double quote + return '\"'; + } + for (int curPos = startPos; curPos <= endPos; curPos++) { if (curPos < endPos) @@ -102,10 +101,10 @@ namespace Discord.Commands continue; } - if(isOpenQuote(command._quotationAliases, c)) + if(IsOpenQuote(command._quotationAliases, c)) { curPart = ParserPart.QuotedParameter; - matchQuote = getMatch(command._quotationAliases, c); + matchQuote = GetMatch(command._quotationAliases, c); continue; } curPart = ParserPart.Parameter;