This repository was archived by the owner on Nov 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- using System . Collections . Generic ;
1+ using System ;
2+ using System . Collections . Generic ;
23using System . Linq ;
34using Discord ;
45using Octokit ;
@@ -15,7 +16,7 @@ public static EmbedBuilder GetEmbed(Issue? issue)
1516 {
1617 if ( issue == null )
1718 {
18- return new EmbedBuilder ( )
19+ return new EmbedBuilder
1920 {
2021 Color = CLOSED_COLOR ,
2122 Description = "No issue or pull request was found."
@@ -26,7 +27,7 @@ public static EmbedBuilder GetEmbed(Issue? issue)
2627 {
2728 Title = $ "{ issue . Title } #{ issue . Number } ",
2829 Url = issue . HtmlUrl ,
29- Description = issue . Body ?? string . Empty ,
30+ Description = LimitLength ( issue . Body , 750 ) ,
3031 Color = GetColor ( issue ) ,
3132 Fields = GetFields ( issue ) . ToList ( ) ,
3233 Author = new EmbedAuthorBuilder
@@ -71,5 +72,13 @@ private static IEnumerable<EmbedFieldBuilder> GetFields(Issue issue)
7172 } ;
7273 }
7374 }
75+
76+ private static string LimitLength ( string ? str , int characterLimit )
77+ {
78+ if ( string . IsNullOrWhiteSpace ( str ) )
79+ return string . Empty ;
80+
81+ return str . Length > characterLimit ? str [ ..( characterLimit - 3 ) ] + "..." : str ;
82+ }
7483 }
7584}
You can’t perform that action at this time.
0 commit comments