Slight update

This commit is contained in:
Toastie 2024-12-26 19:37:56 +13:00
parent 233fd3278b
commit e87208d8bd
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
4 changed files with 46 additions and 4 deletions

View file

@ -32,6 +32,8 @@ internal static class Config
internal static string username = "supportchild"; internal static string username = "supportchild";
internal static string password = ""; internal static string password = "";
internal static JToken interviews;
private static string configPath = "./config.yml"; private static string configPath = "./config.yml";
public static void LoadConfig() public static void LoadConfig()
@ -100,5 +102,8 @@ internal static class Config
database = json.SelectToken("database.name")?.Value<string>() ?? "supportchild"; database = json.SelectToken("database.name")?.Value<string>() ?? "supportchild";
username = json.SelectToken("database.user")?.Value<string>() ?? "supportchild"; username = json.SelectToken("database.user")?.Value<string>() ?? "supportchild";
password = json.SelectToken("database.password")?.Value<string>() ?? ""; password = json.SelectToken("database.password")?.Value<string>() ?? "";
// Set up interviewer
interviews = json.SelectToken("interviews") ?? new JObject();
} }
} }

View file

@ -64,9 +64,15 @@ public static class EventHandler
return; 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<DiscordMessage> messages = await e.Channel.GetMessagesAsync(2); IReadOnlyList<DiscordMessage> 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 try
{ {

View file

@ -145,6 +145,18 @@ internal static class SupportChild
throw; 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..."); Logger.Log("Setting up Discord client...");
DiscordClientBuilder clientBuilder = DiscordClientBuilder.CreateDefault(Config.token, DiscordIntents.All) DiscordClientBuilder clientBuilder = DiscordClientBuilder.CreateDefault(Config.token, DiscordIntents.All)
.SetReconnectOnFatalGatewayErrors() .SetReconnectOnFatalGatewayErrors()

View file

@ -16,7 +16,7 @@
# More info: https://dsharpplus.github.io/api/DSharpPlus.TimestampFormat.html # More info: https://dsharpplus.github.io/api/DSharpPlus.TimestampFormat.html
timestamp-format: "RelativeTime" 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 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. # 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. # Username and password for authentication.
user: "" user: ""
password: "" 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"