2024-12-26 07:47:07 +00:00
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using DSharpPlus.Commands;
|
|
|
|
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
|
|
|
|
using DSharpPlus.Entities;
|
2024-12-26 12:21:37 +00:00
|
|
|
|
using DSharpPlus.Exceptions;
|
2024-12-26 12:54:28 +00:00
|
|
|
|
using SupportChild.Interviews;
|
2024-12-26 07:47:07 +00:00
|
|
|
|
|
|
|
|
|
namespace SupportChild.Commands;
|
|
|
|
|
|
|
|
|
|
public class RestartInterviewCommand
|
|
|
|
|
{
|
|
|
|
|
[Command("restartinterview")]
|
2024-12-26 12:21:37 +00:00
|
|
|
|
[Description("Restarts the automated interview in this ticket, using an updated template if available.")]
|
2024-12-26 07:47:07 +00:00
|
|
|
|
public async Task OnExecute(SlashCommandContext command)
|
|
|
|
|
{
|
2024-12-26 12:21:37 +00:00
|
|
|
|
if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
|
|
|
|
|
{
|
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Red,
|
|
|
|
|
Description = "This channel is not a ticket."
|
|
|
|
|
}, true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-26 07:48:50 +00:00
|
|
|
|
await command.DeferResponseAsync(true);
|
2024-12-26 07:47:07 +00:00
|
|
|
|
await Interviewer.RestartInterview(command);
|
|
|
|
|
await command.RespondAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
|
|
|
|
Description = "Interview restarted."
|
|
|
|
|
}, true);
|
2024-12-26 12:21:37 +00:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
|
|
|
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
|
|
|
{
|
|
|
|
|
Color = DiscordColor.Green,
|
|
|
|
|
Description = command.User.Mention + " restarted interview in " + command.Channel.Mention + ".",
|
|
|
|
|
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
|
|
|
{
|
|
|
|
|
Text = "Ticket: " + ticket.id.ToString("00000")
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
catch (NotFoundException)
|
|
|
|
|
{
|
|
|
|
|
Logger.Error("Could not find the log channel.");
|
|
|
|
|
}
|
2024-12-26 07:47:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|