Skip to content

Commit

Permalink
Add kick command (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Mar 21, 2022
1 parent 1b6a204 commit 8cee05d
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions Hammer/CommandModules/Staff/StaffModule.Kick.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System.Threading.Tasks;
using BrackeysBot.API.Extensions;
using BrackeysBot.Core.API.Attributes;
using DisCatSharp;
using DisCatSharp.CommandsNext;
using DisCatSharp.CommandsNext.Attributes;
using DisCatSharp.Entities;
using Hammer.Data;
using Hammer.Extensions;
using PermissionLevel = BrackeysBot.Core.API.PermissionLevel;

namespace Hammer.CommandModules.Staff;

internal sealed partial class StaffModule
{
[Command("kick")]
[Description("Kicks a member from the guild.")]
[RequirePermissionLevel(PermissionLevel.Administrator)]
public async Task KickCommandAsync(CommandContext context, [Description("The ID of the member to kick.")] ulong memberId,
[Description("The reason for the kick")] [RemainingText]
string? reason = null)
{
await KickCommandAsync(context, await context.Guild.GetMemberAsync(memberId), reason);
}

[Command("kick")]
[Description("Kicks a member from the guild.")]
[RequirePermissionLevel(PermissionLevel.Administrator)]
public async Task KickCommandAsync(CommandContext context, [Description("The member to kick.")] DiscordMember member,
[Description("The reason for the kick")] [RemainingText]
string? reason = null)
{
await context.AcknowledgeAsync();
Infraction infraction = await _infractionService.KickAsync(member, context.Member, reason);

var embed = new DiscordEmbedBuilder();
embed.WithColor(0xFF0000);
embed.WithAuthor(member);
embed.WithTitle("Kicked");
embed.WithDescription(infraction.Reason.WithWhiteSpaceAlternative(Formatter.Italic("<no reason specified>")));
embed.WithFooter($"Infraction #{infraction.Id} \u2022 User #{member.Id}");

await context.RespondAsync(embed);
}
}

0 comments on commit 8cee05d

Please sign in to comment.