Add command to restart interviews
This commit is contained in:
parent
d9fcef449a
commit
e2494c73d4
4 changed files with 44 additions and 2 deletions
|
@ -211,6 +211,7 @@ public class AdminCommands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RequireGuild]
|
||||||
[Command("reload")]
|
[Command("reload")]
|
||||||
[Description("Reloads the bot config.")]
|
[Description("Reloads the bot config.")]
|
||||||
public async Task Reload(SlashCommandContext command)
|
public async Task Reload(SlashCommandContext command)
|
||||||
|
@ -224,6 +225,7 @@ public class AdminCommands
|
||||||
await SupportChild.Reload();
|
await SupportChild.Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RequireGuild]
|
||||||
[Command("getinterviewtemplates")]
|
[Command("getinterviewtemplates")]
|
||||||
[Description("Provides a copy of the interview templates which you can edit and then reupload.")]
|
[Description("Provides a copy of the interview templates which you can edit and then reupload.")]
|
||||||
public async Task GetInterviewTemplates(SlashCommandContext command)
|
public async Task GetInterviewTemplates(SlashCommandContext command)
|
||||||
|
@ -232,6 +234,7 @@ public class AdminCommands
|
||||||
await command.RespondAsync(new DiscordInteractionResponseBuilder().AddFile("interview-templates.json", stream).AsEphemeral());
|
await command.RespondAsync(new DiscordInteractionResponseBuilder().AddFile("interview-templates.json", stream).AsEphemeral());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RequireGuild]
|
||||||
[Command("setinterviewtemplates")]
|
[Command("setinterviewtemplates")]
|
||||||
[Description("Uploads an interview template file.")]
|
[Description("Uploads an interview template file.")]
|
||||||
public async Task SetInterviewTemplates(SlashCommandContext command, [Parameter("file")] DiscordAttachment file)
|
public async Task SetInterviewTemplates(SlashCommandContext command, [Parameter("file")] DiscordAttachment file)
|
||||||
|
|
23
Commands/RestartInterviewCommand.cs
Normal file
23
Commands/RestartInterviewCommand.cs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.Commands;
|
||||||
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
|
||||||
|
namespace SupportChild.Commands;
|
||||||
|
|
||||||
|
public class RestartInterviewCommand
|
||||||
|
{
|
||||||
|
[Command("restartinterview")]
|
||||||
|
[Description("Restarts the automated interview in this channel, using an updated template if available.")]
|
||||||
|
public async Task OnExecute(SlashCommandContext command)
|
||||||
|
{
|
||||||
|
await command.DeferResponseAsync();
|
||||||
|
await Interviewer.RestartInterview(command);
|
||||||
|
await command.RespondAsync(new DiscordEmbedBuilder
|
||||||
|
{
|
||||||
|
Color = DiscordColor.Green,
|
||||||
|
Description = "Interview restarted."
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.Commands.Processors.SlashCommands;
|
||||||
using DSharpPlus.Entities;
|
using DSharpPlus.Entities;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
|
@ -251,6 +252,20 @@ public static class Interviewer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task RestartInterview(SlashCommandContext command)
|
||||||
|
{
|
||||||
|
if (activeInterviews.TryGetValue(command.Channel.Id, out InterviewQuestion interviewRoot))
|
||||||
|
{
|
||||||
|
await DeletePreviousMessages(interviewRoot, command.Channel);
|
||||||
|
if (!Database.TryDeleteInterview(command.Channel.Id))
|
||||||
|
{
|
||||||
|
Logger.Error("Could not delete interview from database. Channel ID: " + command.Channel.Id);
|
||||||
|
}
|
||||||
|
ReloadInterviews();
|
||||||
|
}
|
||||||
|
StartInterview(command.Channel);
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task ProcessButtonOrSelectorResponse(DiscordInteraction interaction)
|
public static async Task ProcessButtonOrSelectorResponse(DiscordInteraction interaction)
|
||||||
{
|
{
|
||||||
if (interaction?.Channel == null || interaction?.Message == null)
|
if (interaction?.Channel == null || interaction?.Message == null)
|
||||||
|
|
|
@ -190,6 +190,7 @@ internal static class SupportChild
|
||||||
typeof(AddCommand),
|
typeof(AddCommand),
|
||||||
typeof(AddMessageCommand),
|
typeof(AddMessageCommand),
|
||||||
typeof(AddStaffCommand),
|
typeof(AddStaffCommand),
|
||||||
|
typeof(AdminCommands),
|
||||||
typeof(AssignCommand),
|
typeof(AssignCommand),
|
||||||
typeof(BlacklistCommand),
|
typeof(BlacklistCommand),
|
||||||
typeof(CloseCommand),
|
typeof(CloseCommand),
|
||||||
|
@ -205,6 +206,7 @@ internal static class SupportChild
|
||||||
typeof(RemoveCategoryCommand),
|
typeof(RemoveCategoryCommand),
|
||||||
typeof(RemoveMessageCommand),
|
typeof(RemoveMessageCommand),
|
||||||
typeof(RemoveStaffCommand),
|
typeof(RemoveStaffCommand),
|
||||||
|
typeof(RestartInterviewCommand),
|
||||||
typeof(SayCommand),
|
typeof(SayCommand),
|
||||||
typeof(SetSummaryCommand),
|
typeof(SetSummaryCommand),
|
||||||
typeof(StatusCommand),
|
typeof(StatusCommand),
|
||||||
|
@ -212,8 +214,7 @@ internal static class SupportChild
|
||||||
typeof(ToggleActiveCommand),
|
typeof(ToggleActiveCommand),
|
||||||
typeof(TranscriptCommand),
|
typeof(TranscriptCommand),
|
||||||
typeof(UnassignCommand),
|
typeof(UnassignCommand),
|
||||||
typeof(UnblacklistCommand),
|
typeof(UnblacklistCommand)
|
||||||
typeof(AdminCommands)
|
|
||||||
]);
|
]);
|
||||||
extension.AddProcessor(new SlashCommandProcessor());
|
extension.AddProcessor(new SlashCommandProcessor());
|
||||||
extension.CommandErrored += EventHandler.OnCommandError;
|
extension.CommandErrored += EventHandler.OnCommandError;
|
||||||
|
|
Loading…
Reference in a new issue