1- using CSharpVitamins ;
2- using DSharpPlus . Entities ;
1+ using DSharpPlus . Entities ;
32using DSharpPlus . SlashCommands ;
43using DSharpPlus . SlashCommands . Attributes ;
54using Present . Data ;
@@ -12,21 +11,14 @@ internal sealed partial class GiveawayCommand
1211 [ SlashCommand ( CommandNames . Redraw , CommandDescriptions . Redraw , false ) ]
1312 [ SlashRequireGuild ]
1413 public async Task RedrawAsync ( InteractionContext context ,
15- [ Option ( OptionNames . Id , OptionDescriptions . RedrawGiveawayId ) ] string idRaw ,
14+ [ Option ( OptionNames . Id , OptionDescriptions . RedrawGiveawayId ) ] long giveawayId ,
1615 [ Option ( OptionNames . KeepIds , OptionDescriptions . RedrawKeep ) ] string ? keepIds = null
1716 )
1817 {
1918 var embed = new DiscordEmbedBuilder ( ) ;
2019 embed . WithColor ( DiscordColor . Red ) ;
2120 embed . WithTitle ( EmbedStrings . InvalidGiveawayId ) ;
2221
23- if ( ! ShortGuid . TryParse ( idRaw , out ShortGuid giveawayId ) )
24- {
25- embed . WithDescription ( string . Format ( EmbedStrings . InvalidId , idRaw ) ) ;
26- await context . CreateResponseAsync ( embed , true ) . ConfigureAwait ( false ) ;
27- return ;
28- }
29-
3022 DiscordGuild guild = context . Guild ;
3123 if ( ! _giveawayService . TryGetGiveaway ( giveawayId , out Giveaway ? giveaway ) || giveaway . GuildId != guild . Id )
3224 {
@@ -49,22 +41,26 @@ public async Task RedrawAsync(InteractionContext context,
4941 {
5042 foreach ( string keepId in keepIds . Split ( ( char [ ] ? ) null , StringSplitOptions . RemoveEmptyEntries ) )
5143 {
52- if ( ulong . TryParse ( keepId , out ulong userId ) &&
53- _giveawayService . ValidateUser ( userId , guild , out DiscordMember ? member ) )
54- keep . Add ( member ) ;
55- else
44+ if ( ! ulong . TryParse ( keepId , out ulong userId ) )
45+ {
5646 invalidKeepIds . Add ( keepId ) ;
47+ continue ;
48+ }
49+
50+ DiscordMember ? member = await _giveawayService . ValidateUserAsync ( userId , giveaway ) . ConfigureAwait ( false ) ;
51+ if ( member is null ) invalidKeepIds . Add ( keepId ) ;
52+ else keep . Add ( member ) ;
5753 }
5854 }
5955
60- IReadOnlyList < DiscordMember > winners = _giveawayService . SelectWinners ( giveaway , keep ) ;
56+ IReadOnlyList < DiscordMember > winners = await _giveawayService . SelectWinnersAsync ( giveaway , keep ) . ConfigureAwait ( false ) ;
6157 await _giveawayService . UpdateWinnersAsync ( giveaway , winners ) . ConfigureAwait ( false ) ;
6258
6359 await _giveawayService . EditGiveawayAsync ( giveaway ) . ConfigureAwait ( false ) ;
6460 await _giveawayService . UpdateGiveawayLogMessageAsync ( giveaway ) . ConfigureAwait ( false ) ;
6561 await _giveawayService . UpdateGiveawayPublicMessageAsync ( giveaway ) . ConfigureAwait ( false ) ;
6662
67- embed = _giveawayService . CreateGiveawayInformationEmbed ( giveaway ) ;
63+ embed = await _giveawayService . CreateGiveawayInformationEmbedAsync ( giveaway ) . ConfigureAwait ( false ) ;
6864 embed . WithColor ( DiscordColor . Green ) ;
6965 embed . WithTitle ( EmbedStrings . GiveawayEdited_Title ) ;
7066
0 commit comments