Skip to content

Commit b7306d1

Browse files
committed
Merge branch 'develop' into main
2 parents 275e94f + 658a668 commit b7306d1

6 files changed

Lines changed: 62 additions & 1 deletion

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using CSharpVitamins;
2+
using DSharpPlus.Entities;
3+
using DSharpPlus.SlashCommands;
4+
using DSharpPlus.SlashCommands.Attributes;
5+
using Present.Data;
6+
using Present.Resources;
7+
using X10D.DSharpPlus;
8+
9+
namespace Present.Commands;
10+
11+
internal sealed partial class GiveawayCommand
12+
{
13+
[SlashCommand(CommandNames.ViewEntrants, CommandDescriptions.ViewEntrants, false)]
14+
[SlashRequireGuild]
15+
public async Task ViewEntrantsAsync(InteractionContext context,
16+
[Option(OptionNames.Id, OptionDescriptions.ViewGiveawayId)] string idRaw
17+
)
18+
{
19+
var embed = new DiscordEmbedBuilder();
20+
embed.WithColor(DiscordColor.Red);
21+
embed.WithTitle(EmbedStrings.InvalidGiveawayId);
22+
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+
30+
DiscordGuild guild = context.Guild;
31+
if (!_giveawayService.TryGetGiveaway(giveawayId, out Giveaway? giveaway) || giveaway.GuildId != guild.Id)
32+
{
33+
embed.WithDescription(string.Format(EmbedStrings.NoGiveawayFound, giveawayId));
34+
await context.CreateResponseAsync(embed, true).ConfigureAwait(false);
35+
return;
36+
}
37+
38+
embed.WithColor(DiscordColor.CornflowerBlue);
39+
embed.WithTitle(EmbedStrings.GiveawayEntrants);
40+
41+
embed.AddField("Entrants", giveaway.Entrants.Count.ToString("0"));
42+
if (giveaway.Entrants.Count > 0)
43+
embed.WithDescription(string.Join('\n', giveaway.Entrants.Select(e => $"• {MentionUtility.MentionUser(e)} ({e:0})")));
44+
45+
await context.CreateResponseAsync(embed).ConfigureAwait(false);
46+
}
47+
}

Present/Present.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
9-
<VersionPrefix>1.4.0</VersionPrefix>
9+
<VersionPrefix>1.5.0</VersionPrefix>
1010
</PropertyGroup>
1111

1212
<PropertyGroup Condition="'$(VersionSuffix)' != '' And '$(BuildNumber)' == ''">

Present/Resources/CommandDescriptions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ internal static class CommandDescriptions
1212
public const string SetWinners = "Updates the number of winners in an ongoing giveaway.";
1313
public const string UnblockRole = "Unblocks a role, so they are able to win giveaways.";
1414
public const string UnblockUser = "Unblocks a user, so they are able to win giveaways.";
15+
public const string ViewEntrants = "View the entrants of a giveaway.";
1516
public const string ViewGiveaway = "View the details of a giveaway.";
1617
}

Present/Resources/CommandNames.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ internal static class CommandNames
1111
public const string Redraw = "redraw";
1212
public const string SetWinners = "setwinners";
1313
public const string View = "view";
14+
public const string ViewEntrants = "viewentrants";
1415
public const string UnblockRole = "unblockrole";
1516
public const string UnblockUser = "unblockuser";
1617
}

Present/Resources/EmbedStrings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Present/Resources/EmbedStrings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<value>The following IDs were ignored because they correspond to invalid or excluded members: {0}</value>
127127
</data>
128128

129+
<data name="GiveawayEntrants" xml:space="preserve">
130+
<value>Giveaway Entrants</value>
131+
</data>
129132
<data name="GiveawayInformation" xml:space="preserve">
130133
<value>Giveaway Information</value>
131134
</data>

0 commit comments

Comments
 (0)