SupportChild/Commands/RestartInterviewCommand.cs

52 lines
1.7 KiB
C#
Raw Normal View History

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;
using DSharpPlus.Exceptions;
2024-12-26 07:47:07 +00:00
namespace SupportChild.Commands;
public class RestartInterviewCommand
{
[Command("restartinterview")]
[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)
{
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;
}
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);
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
}
}