2024-12-26 05:36:20 +00:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using DSharpPlus.Commands;
|
|
|
|
|
using DSharpPlus.Commands.ContextChecks;
|
|
|
|
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
2022-05-19 11:38:59 +00:00
|
|
|
|
using DSharpPlus.Entities;
|
2024-12-26 05:57:41 +00:00
|
|
|
|
using DSharpPlus.Exceptions;
|
2022-05-19 11:38:59 +00:00
|
|
|
|
|
2022-08-21 07:34:11 +00:00
|
|
|
|
namespace SupportChild.Commands;
|
|
|
|
|
|
2024-12-26 05:36:20 +00:00
|
|
|
|
public class UnassignCommand
|
2022-05-19 11:38:59 +00:00
|
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
|
[RequireGuild]
|
|
|
|
|
[Command("unassign")]
|
|
|
|
|
[Description("Unassigns a staff member from a ticket.")]
|
|
|
|
|
public async Task OnExecute(SlashCommandContext command)
|
2024-10-29 09:10:37 +00:00
|
|
|
|
{
|
|
|
|
|
// Check if ticket exists in the database
|
|
|
|
|
if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
|
|
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 09:10:37 +00:00
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "This channel is not a ticket."
|
|
|
|
|
}, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-05-19 11:38:59 +00:00
|
|
|
|
|
2024-10-29 09:10:37 +00:00
|
|
|
|
if (!Database.UnassignStaff(ticket))
|
|
|
|
|
{
|
2024-12-26 05:36:20 +00:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 09:10:37 +00:00
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "Error: Failed to unassign staff member from ticket."
|
|
|
|
|
}, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-05-19 11:38:59 +00:00
|
|
|
|
|
2024-12-26 05:36:20 +00:00
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
2024-10-29 09:10:37 +00:00
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
2024-12-27 06:30:30 +00:00
|
|
|
|
Description = "Unassigned <@" + ticket.assignedStaffID + "> from ticket."
|
2024-10-29 09:10:37 +00:00
|
|
|
|
});
|
2022-05-19 11:38:59 +00:00
|
|
|
|
|
2024-12-27 07:17:14 +00:00
|
|
|
|
await LogChannel.Success("<@" + ticket.assignedStaffID + "> was unassigned from <#" + ticket.channelID + "> by " + command.User.Mention + ".", ticket.id);
|
2024-10-29 09:10:37 +00:00
|
|
|
|
}
|
2022-05-19 11:38:59 +00:00
|
|
|
|
}
|