fix: accept channel ID in MatchChannel

This commit is contained in:
spiral 2021-10-29 13:04:41 -04:00
parent 456545efe8
commit 13fa78987c
No known key found for this signature in database
GPG Key ID: A6059F0CA0E1BD31

View File

@ -83,13 +83,12 @@ namespace PluralKit.Bot.Utils
/// </summary> /// </summary>
public static bool TryParseChannel(string text, out ulong channelId) public static bool TryParseChannel(string text, out ulong channelId)
{ {
if (text.Length >= 3 && text[0] == '<' && text[1] == '#' && text[text.Length - 1] == '>') if (text.Length > 3 && text[0] == '<' && text[1] == '#' && text[text.Length - 1] == '>')
{
text = text.Substring(2, text.Length - 3); //<#123> text = text.Substring(2, text.Length - 3); //<#123>
if (ulong.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out channelId)) if (ulong.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out channelId))
return true; return true;
}
channelId = 0; channelId = 0;
return false; return false;
} }