Skip to content

Commit

Permalink
fix: Added Msg.Content Null Check For Prefixes (#1200)
Browse files Browse the repository at this point in the history
* Added Msg.Content Null Check

* Minor Change

* Grouped Params In If Statement

* Minor Change
  • Loading branch information
ComputerMaster1st authored and foxbot committed Nov 29, 2018
1 parent 7366cd4 commit 46e2674
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Discord.Net.Commands/Extensions/MessageExtensions.cs
Expand Up @@ -19,7 +19,7 @@ public static class MessageExtensions
public static bool HasCharPrefix(this IUserMessage msg, char c, ref int argPos)
{
var text = msg.Content;
if (text.Length > 0 && text[0] == c)
if (!string.IsNullOrEmpty(text) && text[0] == c)
{
argPos = 1;
return true;
Expand All @@ -32,7 +32,7 @@ public static bool HasCharPrefix(this IUserMessage msg, char c, ref int argPos)
public static bool HasStringPrefix(this IUserMessage msg, string str, ref int argPos, StringComparison comparisonType = StringComparison.Ordinal)
{
var text = msg.Content;
if (text.StartsWith(str, comparisonType))
if (!string.IsNullOrEmpty(text) && text.StartsWith(str, comparisonType))
{
argPos = str.Length;
return true;
Expand All @@ -45,7 +45,7 @@ public static bool HasStringPrefix(this IUserMessage msg, string str, ref int ar
public static bool HasMentionPrefix(this IUserMessage msg, IUser user, ref int argPos)
{
var text = msg.Content;
if (text.Length <= 3 || text[0] != '<' || text[1] != '@') return false;
if (string.IsNullOrEmpty(text) || text.Length <= 3 || text[0] != '<' || text[1] != '@') return false;

int endPos = text.IndexOf('>');
if (endPos == -1) return false;
Expand Down

0 comments on commit 46e2674

Please sign in to comment.