Browse Source

Resolve Length issues per #1012

pull/1010/head
Alex Gravely 8 years ago
parent
commit
e46e202abe
1 changed files with 13 additions and 1 deletions
  1. +13
    -1
      src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs

+ 13
- 1
src/Discord.Net.Core/Entities/Messages/EmbedBuilder.cs View File

@@ -86,7 +86,19 @@ namespace Discord
public EmbedAuthorBuilder Author { get; set; } public EmbedAuthorBuilder Author { get; set; }
public EmbedFooterBuilder Footer { get; set; } public EmbedFooterBuilder Footer { get; set; }


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);

return titleLength + authorLength + descriptionLength + footerLength + fieldSum;
}
}


public EmbedBuilder WithTitle(string title) public EmbedBuilder WithTitle(string title)
{ {


Loading…
Cancel
Save