Skip to content

Commit

Permalink
Add User context menu to view infraction history
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Jul 25, 2022
1 parent 1eacee7 commit c6a244d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Hammer/Commands/Infractions/HistoryCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DSharpPlus.Entities;
using DSharpPlus;
using DSharpPlus.Entities;
using DSharpPlus.SlashCommands;
using DSharpPlus.SlashCommands.Attributes;
using Hammer.Services;
Expand All @@ -21,6 +22,20 @@ public HistoryCommand(InfractionService infractionService)
_infractionService = infractionService;
}

[ContextMenu(ApplicationCommandType.UserContextMenu, "View Infraction History", false)]
[SlashRequireGuild]
public async Task HistoryAsync(ContextMenuContext context)
{
DiscordUser user = context.Interaction.Data.Resolved.Users.First().Value;

await context.DeferAsync(true).ConfigureAwait(false);
DiscordEmbedBuilder embed = _infractionService.BuildInfractionHistoryEmbed(user, context.Guild, true);

var builder = new DiscordWebhookBuilder();
builder.AddEmbed(embed);
await context.EditResponseAsync(builder).ConfigureAwait(false);
}

[SlashCommand("history", "Views the infraction history for a user.", false)]
[SlashRequireGuild]
public async Task HistoryAsync(InteractionContext context,
Expand Down

0 comments on commit c6a244d

Please sign in to comment.