Add config entries for interviews
This commit is contained in:
parent
b02aacadd6
commit
3d2d987dfe
4 changed files with 46 additions and 8 deletions
|
@ -114,7 +114,9 @@ public class NewCommand
|
|||
return (false, "You cannot use this command in a ticket channel.");
|
||||
}
|
||||
|
||||
if (!Database.IsStaff(userID) && Database.TryGetOpenTickets(userID, out List<Database.Ticket> ownTickets) && ownTickets.Count >= Config.ticketLimit)
|
||||
if (!Database.IsStaff(userID)
|
||||
&& Database.TryGetOpenTickets(userID, out List<Database.Ticket> ownTickets)
|
||||
&& (ownTickets.Count >= Config.ticketLimit && Config.ticketLimit != 0))
|
||||
{
|
||||
return (false, "You have reached the limit for maximum open tickets.");
|
||||
}
|
||||
|
@ -187,6 +189,7 @@ public class NewCommand
|
|||
}
|
||||
|
||||
DiscordMessage message = await ticketChannel.SendMessageAsync("Hello, " + member.Mention + "!\n" + Config.welcomeMessage);
|
||||
|
||||
if (Config.pinFirstMessage)
|
||||
{
|
||||
try
|
||||
|
@ -202,6 +205,11 @@ public class NewCommand
|
|||
// Refreshes the channel as changes were made to it above
|
||||
ticketChannel = await SupportChild.client.GetChannelAsync(ticketChannel.Id);
|
||||
|
||||
if (Config.interviewsEnabled)
|
||||
{
|
||||
Interviewer.StartInterview(ticketChannel);
|
||||
}
|
||||
|
||||
if (staffID != 0)
|
||||
{
|
||||
await ticketChannel.SendMessageAsync(new DiscordEmbedBuilder
|
||||
|
|
13
Config.cs
13
Config.cs
|
@ -26,6 +26,10 @@ internal static class Config
|
|||
internal static bool assignmentNotifications = false;
|
||||
internal static bool closingNotifications = false;
|
||||
|
||||
internal static bool interviewsEnabled = false;
|
||||
internal static bool deleteMessagesAfterSummary = false;
|
||||
internal static bool deleteMessagesAfterNoSummary = false;
|
||||
|
||||
internal static string hostName = "127.0.0.1";
|
||||
internal static int port = 3306;
|
||||
internal static string database = "supportchild";
|
||||
|
@ -69,16 +73,15 @@ internal static class Config
|
|||
if (!Enum.TryParse(stringLogLevel, true, out LogLevel logLevel))
|
||||
{
|
||||
logLevel = LogLevel.Information;
|
||||
Logger.Warn("Log level '" + stringLogLevel + "' invalid, using 'Information' instead.");
|
||||
Logger.Warn("Log level '" + stringLogLevel + "' is invalid, using 'Information' instead.");
|
||||
}
|
||||
Logger.SetLogLevel(logLevel);
|
||||
|
||||
string stringTimestampFormat = json.SelectToken("bot.timestamp-format")?.Value<string>() ?? "RelativeTime";
|
||||
|
||||
if (!Enum.TryParse(stringTimestampFormat, true, out timestampFormat))
|
||||
{
|
||||
timestampFormat = TimestampFormat.RelativeTime;
|
||||
Logger.Warn("Timestamp '" + stringTimestampFormat + "' invalid, using 'RelativeTime' instead.");
|
||||
Logger.Warn("Timestamp '" + stringTimestampFormat + "' is invalid, using 'RelativeTime' instead.");
|
||||
}
|
||||
|
||||
randomAssignment = json.SelectToken("bot.random-assignment")?.Value<bool>() ?? false;
|
||||
|
@ -94,6 +97,10 @@ internal static class Config
|
|||
assignmentNotifications = json.SelectToken("notifications.assignment")?.Value<bool>() ?? false;
|
||||
closingNotifications = json.SelectToken("notifications.closing")?.Value<bool>() ?? false;
|
||||
|
||||
interviewsEnabled = json.SelectToken("interviews.enabled")?.Value<bool>() ?? false;
|
||||
deleteMessagesAfterSummary = json.SelectToken("interviews.delete-messages-after-summary")?.Value<bool>() ?? false;
|
||||
deleteMessagesAfterNoSummary = json.SelectToken("interviews.delete-messages-after-no-summary")?.Value<bool>() ?? false;
|
||||
|
||||
// Reads database info
|
||||
hostName = json.SelectToken("database.address")?.Value<string>() ?? "";
|
||||
port = json.SelectToken("database.port")?.Value<int>() ?? 3306;
|
||||
|
|
|
@ -352,7 +352,11 @@ public static class Interviewer
|
|||
{
|
||||
if (Database.TryGetInterview(command.Channel.Id, out InterviewQuestion interviewRoot))
|
||||
{
|
||||
await DeletePreviousMessages(interviewRoot, command.Channel);
|
||||
if (Config.deleteMessagesAfterNoSummary)
|
||||
{
|
||||
await DeletePreviousMessages(interviewRoot, command.Channel);
|
||||
}
|
||||
|
||||
if (!Database.TryDeleteInterview(command.Channel.Id))
|
||||
{
|
||||
Logger.Error("Could not delete interview from database. Channel ID: " + command.Channel.Id);
|
||||
|
@ -624,7 +628,11 @@ public static class Interviewer
|
|||
|
||||
await channel.SendMessageAsync(embed);
|
||||
|
||||
await DeletePreviousMessages(interviewRoot, channel);
|
||||
if (Config.deleteMessagesAfterSummary)
|
||||
{
|
||||
await DeletePreviousMessages(interviewRoot, channel);
|
||||
}
|
||||
|
||||
if (!Database.TryDeleteInterview(channel.Id))
|
||||
{
|
||||
Logger.Error("Could not delete interview from database. Channel ID: " + channel.Id);
|
||||
|
@ -638,7 +646,11 @@ public static class Interviewer
|
|||
Description = nextQuestion.message
|
||||
});
|
||||
|
||||
await DeletePreviousMessages(interviewRoot, channel);
|
||||
if (Config.deleteMessagesAfterNoSummary)
|
||||
{
|
||||
await DeletePreviousMessages(interviewRoot, channel);
|
||||
}
|
||||
|
||||
if (!Database.TryDeleteInterview(channel.Id))
|
||||
{
|
||||
Logger.Error("Could not delete interview from database. Channel ID: " + channel.Id);
|
||||
|
|
|
@ -48,11 +48,22 @@ notifications:
|
|||
ticket-updated-delay: 0.5
|
||||
|
||||
# Notifies staff when they are assigned to tickets.
|
||||
assignment: true
|
||||
assignment: true # TODO: Add option to be notified only when the initial interview is finished.
|
||||
|
||||
# Notifies the user opening the ticket that their ticket was closed and includes the transcript.
|
||||
closing: true
|
||||
|
||||
interviews: # TODO: Implement
|
||||
# Enable the interview system. You must use the admin commands to set up interview templates before you can start using it.
|
||||
# Any existing interviews can still be completed while interviews are disabled, but new ones will not be created.
|
||||
enabled: true
|
||||
|
||||
# Whether to delete the interview question and answer messages after an interview summary is posted.
|
||||
delete-messages-after-summary: true
|
||||
|
||||
# Whether to delete the interview question and answer messages after an interview ends without a summary.
|
||||
delete-messages-after-no-summary: true
|
||||
|
||||
database:
|
||||
# Address and port of the mysql server.
|
||||
address: "127.0.0.1"
|
||||
|
|
Loading…
Reference in a new issue