diff --git a/Config.cs b/Config.cs index 351ecdc..1993673 100644 --- a/Config.cs +++ b/Config.cs @@ -32,6 +32,8 @@ internal static class Config internal static string username = "supportchild"; internal static string password = ""; + internal static JToken interviews; + private static string configPath = "./config.yml"; public static void LoadConfig() @@ -100,5 +102,8 @@ internal static class Config database = json.SelectToken("database.name")?.Value() ?? "supportchild"; username = json.SelectToken("database.user")?.Value() ?? "supportchild"; password = json.SelectToken("database.password")?.Value() ?? ""; + + // Set up interviewer + interviews = json.SelectToken("interviews") ?? new JObject(); } } \ No newline at end of file diff --git a/EventHandler.cs b/EventHandler.cs index 06aa5fc..14db8cb 100644 --- a/EventHandler.cs +++ b/EventHandler.cs @@ -64,9 +64,15 @@ public static class EventHandler return; } - // Sends a DM to the assigned staff member if at least a day has gone by since the last message and the user sending the message isn't staff + // Ignore staff messages + if (Database.IsStaff(e.Author.Id)) + { + return; + } + + // Sends a DM to the assigned staff member if at least a day has gone by since the last message IReadOnlyList messages = await e.Channel.GetMessagesAsync(2); - if (messages.Count > 1 && messages[1].Timestamp < DateTimeOffset.UtcNow.AddDays(Config.ticketUpdatedNotificationDelay * -1) && !Database.IsStaff(e.Author.Id)) + if (messages.Count > 1 && messages[1].Timestamp < DateTimeOffset.UtcNow.AddDays(Config.ticketUpdatedNotificationDelay * -1)) { try { diff --git a/SupportChild.cs b/SupportChild.cs index 68a290f..c78452f 100644 --- a/SupportChild.cs +++ b/SupportChild.cs @@ -145,6 +145,18 @@ internal static class SupportChild throw; } + try + { + Logger.Log("Connecting to database... (" + Config.hostName + ":" + Config.port + ")"); + Interviewer.ParseConfig(Config.interviews); + Interviewer.LoadActiveInterviews(); + } + catch (Exception e) + { + Logger.Fatal("Could not set up database tables, please confirm connection settings, status of the server and permissions of MySQL user. Error: " + e); + throw; + } + Logger.Log("Setting up Discord client..."); DiscordClientBuilder clientBuilder = DiscordClientBuilder.CreateDefault(Config.token, DiscordIntents.All) .SetReconnectOnFatalGatewayErrors() diff --git a/default_config.yml b/default_config.yml index 3e0e443..e4c83f3 100644 --- a/default_config.yml +++ b/default_config.yml @@ -16,7 +16,7 @@ # More info: https://dsharpplus.github.io/api/DSharpPlus.TimestampFormat.html timestamp-format: "RelativeTime" - # Whether or not staff members should be randomly assigned tickets when they are made. Individual staff members can opt out using the toggleactive command. + # Whether staff members should be randomly assigned tickets when they are made. Individual staff members can opt out using the toggleactive command. random-assignment: true # If set to true the rasssign command will include staff members set as inactive if a specific role is specified in the command. @@ -63,4 +63,23 @@ database: # Username and password for authentication. user: "" - password: "" \ No newline at end of file + password: "" + +# TODO: May want to move interview entries to subkey to make room for additional interview settings +interviews: + 000000000000000000: + message: "Are you appealing your own ban or on behalf of another user?" + type: "BUTTONS" + color: "CYAN" + paths: + - "My own ban": # TODO: Can I add button color support somehow? + text: "What is your user name?" + type: "TEXT_INPUT" + summary-field: "Username" + paths: + - ".*": + text: "Please write your appeal below, motivate why you think you should be unbanned." + - "Another user's ban": + text: "You can only appeal your own ban. Please close this ticket." + type: "FAIL" + color: "CYAN" \ No newline at end of file