From 173df19439a7bf9bf4e5f8d749f91b5abb9c4b07 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sun, 14 Feb 2016 13:45:58 -0400 Subject: [PATCH] Fixed crash with short mention activation strings --- src/Discord.Net.Commands/CommandService.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 5969b9691..8e6f42c51 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -97,10 +97,15 @@ namespace Discord.Commands //Check for mention if (cmdMsg == null && Config.AllowMentionPrefix) { - if (msg.StartsWith(client.CurrentUser.Mention)) - cmdMsg = msg.Substring(client.CurrentUser.Mention.Length + 1); - else if (msg.StartsWith($"@{client.CurrentUser.Name}")) - cmdMsg = msg.Substring(client.CurrentUser.Name.Length + 1); + string mention = client.CurrentUser.Mention; + if (msg.StartsWith(mention) && msg.Length > mention.Length) + cmdMsg = msg.Substring(mention.Length + 1); + else + { + mention = $"@{client.CurrentUser.Name}"; + if (msg.StartsWith(mention) && msg.Length > mention.Length) + cmdMsg = msg.Substring(mention.Length + 1); + } } //Check using custom activator