diff --git a/src/Discord.Net.Commands/CommandParser.cs b/src/Discord.Net.Commands/CommandParser.cs index 92e1a95c8..9ce4e1469 100644 --- a/src/Discord.Net.Commands/CommandParser.cs +++ b/src/Discord.Net.Commands/CommandParser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Text; @@ -29,8 +29,8 @@ namespace Discord.Commands // 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 if the key is contained in the dictionary if it is populated + if (dict.Count != 0) return dict.ContainsKey(ch); // or otherwise if it is the default double quote return c == '\"'; @@ -39,7 +39,8 @@ namespace Discord.Commands char GetMatch(IReadOnlyDictionary dict, char ch) { // get the corresponding value for the key, if it exists - if (dict != null && dict.TryGetValue(c, out var value)) + // and if the dictionary is populated + if (dict.Count != 0 && dict.TryGetValue(c, out var value)) return value; // or get the default pair of the default double quote return '\"'; diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 5287cb0ad..82a5d66ad 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; @@ -46,7 +46,7 @@ namespace Discord.Commands _ignoreExtraArgs = config.IgnoreExtraArgs; _separatorChar = config.SeparatorChar; _defaultRunMode = config.DefaultRunMode; - _quotationMarkAliasMap = config.QuotationMarkAliasMap?.ToImmutableDictionary(); + _quotationMarkAliasMap = (config.QuotationMarkAliasMap ?? new Dictionary()).ToImmutableDictionary(); if (_defaultRunMode == RunMode.Default) throw new InvalidOperationException("The default run mode cannot be set to Default.");