@@ -64,37 +64,8 @@ public DiscordEmbed CreatePrivateEmbed(Suggestion suggestion)
6464 return new DiscordEmbedBuilder ( ) ;
6565 }
6666
67- if ( ! _configurationService . TryGetGuildConfiguration ( guild , out GuildConfiguration ? configuration ) )
68- {
69- configuration = new GuildConfiguration ( ) ;
70- }
71-
72- string emoji = suggestion . Status switch
73- {
74- SuggestionStatus . Suggested => "🗳️" ,
75- SuggestionStatus . Rejected => "❌" ,
76- SuggestionStatus . Implemented => "✅" ,
77- SuggestionStatus . Accepted => "✅" ,
78- _ => throw new ArgumentOutOfRangeException ( nameof ( suggestion ) , suggestion . Status , null )
79- } ;
80-
8167 DiscordUser author = GetAuthor ( suggestion ) ;
82- var embed = new DiscordEmbedBuilder ( ) ;
83- string authorName = author . GetUsernameWithDiscriminator ( ) ;
84- embed . WithAuthor ( $ "Suggestion from { authorName } ", iconUrl : author . GetAvatarUrl ( ImageFormat . Png ) ) ;
85- embed . WithThumbnail ( guild . GetIconUrl ( ImageFormat . Png ) ) ;
86- embed . WithDescription ( suggestion . Content ) ;
87- embed . WithFooter ( $ "Suggestion { suggestion . Id } ") ;
88- embed . WithColor ( suggestion . Status switch
89- {
90- SuggestionStatus . Suggested => configuration . SuggestedColor ,
91- SuggestionStatus . Rejected => configuration . RejectedColor ,
92- SuggestionStatus . Implemented => configuration . ImplementedColor ,
93- SuggestionStatus . Accepted => configuration . AcceptedColor ,
94- _ => throw new ArgumentOutOfRangeException ( nameof ( suggestion ) , suggestion . Status , null )
95- } ) ;
96-
97- embed . AddField ( "Status" , $ "{ emoji } **{ suggestion . Status . Humanize ( LetterCasing . AllCaps ) } **", true ) ;
68+ DiscordEmbedBuilder embed = CreateDefaultEmbed ( suggestion , guild ) ;
9869 embed . AddField ( "Author" , author . Mention , true ) ;
9970 embed . AddField ( "Submitted" , Formatter . Timestamp ( suggestion . Timestamp ) , true ) ;
10071 embed . AddField ( "View Suggestion" , GetSuggestionLink ( suggestion ) , true ) ;
@@ -138,39 +109,7 @@ public DiscordEmbed CreatePublicEmbed(Suggestion suggestion)
138109 return new DiscordEmbedBuilder ( ) ;
139110 }
140111
141- if ( ! _configurationService . TryGetGuildConfiguration ( guild , out GuildConfiguration ? configuration ) )
142- {
143- configuration = new GuildConfiguration ( ) ;
144- }
145-
146- string emoji = suggestion . Status switch
147- {
148- SuggestionStatus . Suggested => "🗳️" ,
149- SuggestionStatus . Rejected => "❌" ,
150- SuggestionStatus . Implemented => "✅" ,
151- SuggestionStatus . Accepted => "✅" ,
152- _ => throw new ArgumentOutOfRangeException ( nameof ( suggestion ) , suggestion . Status , null )
153- } ;
154-
155- DiscordUser author = GetAuthor ( suggestion ) ;
156- var embed = new DiscordEmbedBuilder ( ) ;
157- string authorName = author . GetUsernameWithDiscriminator ( ) ;
158- embed . WithAuthor ( $ "Suggestion from { authorName } ", iconUrl : author . GetAvatarUrl ( ImageFormat . Png ) ) ;
159- embed . WithThumbnail ( guild . GetIconUrl ( ImageFormat . Png ) ) ;
160- embed . WithDescription ( suggestion . Content ) ;
161- embed . WithFooter ( $ "Suggestion { suggestion . Id } ") ;
162- embed . WithTimestamp ( suggestion . Timestamp ) ;
163- embed . WithColor ( suggestion . Status switch
164- {
165- SuggestionStatus . Suggested => configuration . SuggestedColor ,
166- SuggestionStatus . Rejected => configuration . RejectedColor ,
167- SuggestionStatus . Implemented => configuration . ImplementedColor ,
168- SuggestionStatus . Accepted => configuration . AcceptedColor ,
169- _ => throw new ArgumentOutOfRangeException ( nameof ( suggestion ) , suggestion . Status , null )
170- } ) ;
171-
172- embed . AddField ( "Status" , $ "{ emoji } **{ suggestion . Status . Humanize ( LetterCasing . AllCaps ) } **", true ) ;
173-
112+ DiscordEmbedBuilder embed = CreateDefaultEmbed ( suggestion , guild ) ;
174113 if ( ! string . IsNullOrWhiteSpace ( suggestion . Remarks ) )
175114 {
176115 embed . AddField ( "Staff Remarks" , suggestion . Remarks ) ;
@@ -695,6 +634,48 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
695634 return Task . CompletedTask ;
696635 }
697636
637+ private DiscordEmbedBuilder CreateDefaultEmbed ( Suggestion suggestion , DiscordGuild guild )
638+ {
639+ if ( ! _configurationService . TryGetGuildConfiguration ( guild , out GuildConfiguration ? configuration ) )
640+ {
641+ configuration = new GuildConfiguration ( ) ;
642+ }
643+
644+ string emoji = suggestion . Status switch
645+ {
646+ SuggestionStatus . Suggested => "🗳️" ,
647+ SuggestionStatus . Rejected => "❌" ,
648+ SuggestionStatus . Implemented => "✅" ,
649+ SuggestionStatus . Accepted => "✅" ,
650+ SuggestionStatus . Duplicate => "🔁" ,
651+ SuggestionStatus . AlreadyImplemented => "✅" ,
652+ SuggestionStatus . AlreadyPlanned => "📅" ,
653+ _ => throw new ArgumentOutOfRangeException ( nameof ( suggestion ) , suggestion . Status , null )
654+ } ;
655+
656+ DiscordUser author = GetAuthor ( suggestion ) ;
657+ var embed = new DiscordEmbedBuilder ( ) ;
658+ string authorName = author . GetUsernameWithDiscriminator ( ) ;
659+ embed . WithAuthor ( $ "Suggestion from { authorName } ", iconUrl : author . GetAvatarUrl ( ImageFormat . Png ) ) ;
660+ embed . WithThumbnail ( guild . GetIconUrl ( ImageFormat . Png ) ) ;
661+ embed . WithDescription ( suggestion . Content ) ;
662+ embed . WithFooter ( $ "Suggestion { suggestion . Id } ") ;
663+ embed . WithTimestamp ( suggestion . Timestamp ) ;
664+ embed . WithColor ( suggestion . Status switch
665+ {
666+ SuggestionStatus . Suggested => configuration . SuggestedColor ,
667+ SuggestionStatus . Rejected => configuration . RejectedColor ,
668+ SuggestionStatus . Implemented or SuggestionStatus . AlreadyImplemented => configuration . ImplementedColor ,
669+ SuggestionStatus . Accepted => configuration . AcceptedColor ,
670+ SuggestionStatus . Duplicate => configuration . DuplicateColor ,
671+ SuggestionStatus . AlreadyPlanned => configuration . PlannedColor ,
672+ _ => throw new ArgumentOutOfRangeException ( nameof ( suggestion ) , suggestion . Status , null )
673+ } ) ;
674+
675+ embed . AddField ( "Status" , $ "{ emoji } **{ suggestion . Status . Humanize ( LetterCasing . AllCaps ) } **", true ) ;
676+ return embed ;
677+ }
678+
698679 private Task OnGuildAvailable ( DiscordClient sender , GuildCreateEventArgs args )
699680 {
700681 DiscordGuild guild = args . Guild ;
0 commit comments