SupportChild/Commands/BlacklistCommand.cs

50 lines
1.6 KiB
C#
Raw Normal View History

2022-04-18 10:52:03 +00:00
using System;
using System.ComponentModel;
2022-02-21 08:40:09 +00:00
using System.Threading.Tasks;
using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands;
2022-02-21 08:40:09 +00:00
using DSharpPlus.Entities;
2024-12-26 05:57:41 +00:00
using DSharpPlus.Exceptions;
2022-02-21 08:40:09 +00:00
2022-08-21 07:34:11 +00:00
namespace SupportChild.Commands;
public class BlacklistCommand
2022-02-21 08:40:09 +00:00
{
[RequireGuild]
[Command("blacklist")]
[Description("Blacklists a user from opening tickets.")]
public async Task OnExecute(SlashCommandContext command,
[Parameter("user")][Description("User to blacklist.")] DiscordUser user)
{
try
{
if (!Database.Blacklist(user.Id, command.User.Id))
{
await command.RespondAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = user.Mention + " is already blacklisted."
}, true);
return;
}
2022-02-21 08:40:09 +00:00
await command.RespondAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = "Blocked " + user.Mention + " from opening new tickets."
}, true);
2022-02-21 08:40:09 +00:00
2024-12-27 07:17:14 +00:00
await LogChannel.Success(user.Mention + " was blocked from opening tickets by " + command.User.Mention + ".");
}
catch (Exception)
{
await command.RespondAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "Error occured while blacklisting " + user.Mention + "."
}, true);
throw;
}
}
2022-05-19 11:38:59 +00:00
}