Skip to content

Commit

Permalink
Fix Embed.Length behavior (#1012)
Browse files Browse the repository at this point in the history
- This commit splits up the get statement lines for better analysis.
  • Loading branch information
Still Hsu authored and foxbot committed Apr 29, 2018
1 parent a4d1e2b commit a3ce80c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/Discord.Net.Core/Entities/Messages/Embed.cs
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -57,7 +57,18 @@ internal Embed(EmbedType type)
Fields = fields;
}

public int Length => Title?.Length + Author?.Name?.Length + Description?.Length + Footer?.Text?.Length + Fields.Sum(f => f.Name.Length + f.Value.ToString().Length) ?? 0;
public int Length
{
get
{
int titleLength = Title?.Length ?? 0;
int authorLength = Author?.Name?.Length ?? 0;
int descriptionLength = Description?.Length ?? 0;
int footerLength = Footer?.Text?.Length ?? 0;
int fieldSum = Fields.Sum(f => f.Name?.Length + f.Value?.ToString().Length) ?? 0;
return titleLength + authorLength + descriptionLength + footerLength + fieldSum;
}
}

public override string ToString() => Title;
private string DebuggerDisplay => $"{Title} ({Type})";
Expand Down

0 comments on commit a3ce80c

Please sign in to comment.