diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index ab8ff9a..2658773 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -1,4 +1,4 @@
-# To get started with Dependabot version updates, you'll need to specify which
+# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
@@ -12,7 +12,7 @@ updates:
open-pull-requests-limit: 5
reviewers:
- EmotionChild
- target-branch: "main"
+ target-branch: "development"
labels:
- "nuget"
- - "dependencies"
+ - "dependencies"
\ No newline at end of file
diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 8f7d9f6..858dcab 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -1,4 +1,4 @@
-name: .NET
+name: .NET
on:
push:
@@ -12,14 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
- - name: Setup .NET
- uses: actions/setup-dotnet@v2
- with:
- dotnet-version: 6.0.x
- - name: Restore dependencies
- run: dotnet restore
- - name: Build
- run: dotnet build --no-restore
- - name: Test
- run: dotnet test --no-build --verbosity normal
+ - uses: actions/checkout@v3
+ - name: Setup .NET
+ uses: actions/setup-dotnet@v2
+ with:
+ dotnet-version: 6.0.x
+ - name: Restore dependencies
+ run: dotnet restore
+ - name: Build
+ run: dotnet build --no-restore
+ - name: Test
+ run: dotnet test --no-build --verbosity normal
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 5e49400..f8206f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -362,5 +362,8 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
+# Manually added folders
Windows-x64/
Linux-x64/
+.idea
+.vs
diff --git a/README.md b/README.md
index 99f8427..c817b08 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
# SupportChild
+
+this is a customized version of [SupportBoi](https://github.com/KarlOfDuty/SupportBoi) it is recommended you go and check out the awesome work that is there!
diff --git a/SupportChild.sln b/SupportChild.sln
index cc9d1b4..098a159 100644
--- a/SupportChild.sln
+++ b/SupportChild.sln
@@ -1,9 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.32126.317
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SupportChild", "SupportChild\SupportChild.csproj", "{9124DF58-D261-4906-8ECA-D853DEBE07D4}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SupportChild", "SupportChild\SupportChild.csproj", "{B043AACB-D763-4C61-9524-C8B7C58DA3EF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -11,15 +8,9 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9124DF58-D261-4906-8ECA-D853DEBE07D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9124DF58-D261-4906-8ECA-D853DEBE07D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9124DF58-D261-4906-8ECA-D853DEBE07D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9124DF58-D261-4906-8ECA-D853DEBE07D4}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {B2CD3447-A8BA-4B02-9E08-A75CBBD2BDCB}
+ {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
diff --git a/SupportChild.sln.DotSettings b/SupportChild.sln.DotSettings
new file mode 100644
index 0000000..b960982
--- /dev/null
+++ b/SupportChild.sln.DotSettings
@@ -0,0 +1,6 @@
+
+ ERROR
+ True
+
+ True
+
\ No newline at end of file
diff --git a/SupportChild/Commands/AddCommand.cs b/SupportChild/Commands/AddCommand.cs
index dd3fcc2..64e5935 100644
--- a/SupportChild/Commands/AddCommand.cs
+++ b/SupportChild/Commands/AddCommand.cs
@@ -8,100 +8,100 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class AddCommand : BaseCommandModule
- {
- [Command("add")]
- [Description("Adds a user to a ticket.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "add"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the add command but did not have permission.");
- return;
- }
+ public class AddCommand : BaseCommandModule
+ {
+ [Command("add")]
+ [Description("Adds a user to a ticket.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "add"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the add command but did not have permission.");
+ return;
+ }
- // Check if ticket exists in the database
- if (!Database.IsOpenTicket(command.Channel.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (!Database.IsOpenTicket(command.Channel.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- string[] parsedArgs = Utilities.ParseIDs(command.RawArgumentString);
- foreach (string parsedArg in parsedArgs)
- {
- if (!ulong.TryParse(parsedArg, out ulong userID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- continue;
- }
+ string[] parsedArgs = Utilities.ParseIDs(command.RawArgumentString);
+ foreach (string parsedArg in parsedArgs)
+ {
+ if (!ulong.TryParse(parsedArg, out ulong userID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ continue;
+ }
- DiscordMember mentionedMember;
- try
- {
- mentionedMember = await command.Guild.GetMemberAsync(userID);
- }
- catch (Exception)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not find user on this server)"
- };
- await command.RespondAsync(error);
- continue;
- }
+ DiscordMember mentionedMember;
+ try
+ {
+ mentionedMember = await command.Guild.GetMemberAsync(userID);
+ }
+ catch (Exception)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not find user on this server)"
+ };
+ await command.RespondAsync(error);
+ continue;
+ }
- try
- {
- await command.Channel.AddOverwriteAsync(mentionedMember, Permissions.AccessChannels, Permissions.None);
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Added " + mentionedMember.Mention + " to ticket."
- };
- await command.RespondAsync(message);
+ try
+ {
+ await command.Channel.AddOverwriteAsync(mentionedMember, Permissions.AccessChannels, Permissions.None);
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Added " + mentionedMember.Mention + " to ticket."
+ };
+ await command.RespondAsync(message);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = mentionedMember.Mention + " was added to " + command.Channel.Mention +
- " by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- catch (Exception)
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Could not add <@" + parsedArg + "> to ticket, unknown error occured."
- };
- await command.RespondAsync(message);
- }
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = mentionedMember.Mention + " was added to " + command.Channel.Mention +
+ " by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ catch (Exception)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Could not add <@" + parsedArg + "> to ticket, unknown error occured."
+ };
+ await command.RespondAsync(message);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/AddMessageCommand.cs b/SupportChild/Commands/AddMessageCommand.cs
index 8aca6b9..a2e6606 100644
--- a/SupportChild/Commands/AddMessageCommand.cs
+++ b/SupportChild/Commands/AddMessageCommand.cs
@@ -39,7 +39,7 @@ namespace SupportChild.Commands
await command.RespondAsync(error);
return;
}
-
+
if (Database.TryGetMessage(identifier.ToLower(), out Database.Message _))
{
DiscordEmbed error = new DiscordEmbedBuilder
@@ -51,7 +51,7 @@ namespace SupportChild.Commands
return;
}
- if (Database.AddMessage(identifier, command.Member.Id, message))
+ if(Database.AddMessage(identifier, command.Member.Id, message))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
@@ -71,7 +71,6 @@ namespace SupportChild.Commands
await command.RespondAsync(error);
return;
}
-
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/AddStaffCommand.cs b/SupportChild/Commands/AddStaffCommand.cs
index e36572a..03f5948 100644
--- a/SupportChild/Commands/AddStaffCommand.cs
+++ b/SupportChild/Commands/AddStaffCommand.cs
@@ -9,88 +9,88 @@ using MySql.Data.MySqlClient;
namespace SupportChild.Commands
{
- public class AddStaffCommand : BaseCommandModule
- {
- [Command("addstaff")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "addstaff"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the addstaff command but did not have permission.");
- return;
- }
+ public class AddStaffCommand : BaseCommandModule
+ {
+ [Command("addstaff")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "addstaff"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the addstaff command but did not have permission.");
+ return;
+ }
- ulong userID;
- string[] parsedArgs = Utilities.ParseIDs(commandArgs);
+ ulong userID;
+ string[] parsedArgs = Utilities.ParseIDs(commandArgs);
- if (!parsedArgs.Any())
- {
- userID = command.Member.Id;
- }
- else if (!ulong.TryParse(parsedArgs[0], out userID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!parsedArgs.Any())
+ {
+ userID = command.Member.Id;
+ }
+ else if (!ulong.TryParse(parsedArgs[0], out userID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- DiscordMember member;
- try
- {
- member = await command.Guild.GetMemberAsync(userID);
- }
- catch (Exception)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not find user on this server)"
- };
- await command.RespondAsync(error);
- return;
- }
+ DiscordMember member;
+ try
+ {
+ member = await command.Guild.GetMemberAsync(userID);
+ }
+ catch (Exception)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not find user on this server)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- using (MySqlConnection c = Database.GetConnection())
- {
- MySqlCommand cmd = Database.IsStaff(userID) ? new MySqlCommand(@"UPDATE staff SET name = @name WHERE user_id = @user_id", c) : new MySqlCommand(@"INSERT INTO staff (user_id, name) VALUES (@user_id, @name);", c);
+ using (MySqlConnection c = Database.GetConnection())
+ {
+ MySqlCommand cmd = Database.IsStaff(userID) ? new MySqlCommand(@"UPDATE staff SET name = @name WHERE user_id = @user_id", c) : new MySqlCommand(@"INSERT INTO staff (user_id, name) VALUES (@user_id, @name);", c);
- c.Open();
- cmd.Parameters.AddWithValue("@user_id", userID);
- cmd.Parameters.AddWithValue("@name", member.DisplayName);
- cmd.ExecuteNonQuery();
- cmd.Dispose();
+ c.Open();
+ cmd.Parameters.AddWithValue("@user_id", userID);
+ cmd.Parameters.AddWithValue("@name", member.DisplayName);
+ cmd.ExecuteNonQuery();
+ cmd.Dispose();
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = member.Mention + " was added to staff."
- };
- await command.RespondAsync(message);
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = member.Mention + " was added to staff."
+ };
+ await command.RespondAsync(message);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = member.Mention + " was added to staff.\n",
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = member.Mention + " was added to staff.\n",
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/AssignCommand.cs b/SupportChild/Commands/AssignCommand.cs
index 2ee07fa..a4660f6 100644
--- a/SupportChild/Commands/AssignCommand.cs
+++ b/SupportChild/Commands/AssignCommand.cs
@@ -8,128 +8,128 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class AssignCommand : BaseCommandModule
- {
- [Command("assign")]
- [Description("Assigns a staff member to a ticket.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "assign"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the assign command but did not have permission.");
- return;
- }
+ public class AssignCommand : BaseCommandModule
+ {
+ [Command("assign")]
+ [Description("Assigns a staff member to a ticket.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "assign"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the assign command but did not have permission.");
+ return;
+ }
- // Check if ticket exists in the database
- if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- ulong staffID;
- string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
+ ulong staffID;
+ string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
- if (!parsedMessage.Any())
- {
- staffID = command.Member.Id;
- }
- else if (!ulong.TryParse(parsedMessage[0], out staffID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!parsedMessage.Any())
+ {
+ staffID = command.Member.Id;
+ }
+ else if (!ulong.TryParse(parsedMessage[0], out staffID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- DiscordMember staffMember = null;
- try
- {
- staffMember = await command.Guild.GetMemberAsync(staffID);
- }
- catch (NotFoundException) { }
+ DiscordMember staffMember = null;
+ try
+ {
+ staffMember = await command.Guild.GetMemberAsync(staffID);
+ }
+ catch (NotFoundException) { }
- if (staffMember == null)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Could not find user."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (staffMember == null)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Could not find user."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (!Database.IsStaff(staffMember.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: User is not registered as staff."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!Database.IsStaff(staffMember.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: User is not registered as staff."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (!Database.AssignStaff(ticket, staffID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Failed to assign " + staffMember.Mention + " to ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!Database.AssignStaff(ticket, staffID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Failed to assign " + staffMember.Mention + " to ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- DiscordEmbed feedback = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Assigned " + staffMember.Mention + " to ticket."
- };
- await command.RespondAsync(feedback);
+ DiscordEmbed feedback = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Assigned " + staffMember.Mention + " to ticket."
+ };
+ await command.RespondAsync(feedback);
- if (Config.assignmentNotifications)
- {
- try
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "You have been assigned to a support ticket: " + command.Channel.Mention
- };
- await staffMember.SendMessageAsync(message);
- }
- catch (UnauthorizedException) { }
+ if (Config.assignmentNotifications)
+ {
+ try
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "You have been assigned to a support ticket: " + command.Channel.Mention
+ };
+ await staffMember.SendMessageAsync(message);
+ }
+ catch (UnauthorizedException) {}
- }
+ }
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = staffMember.Mention + " was assigned to " + command.Channel.Mention + " by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = staffMember.Mention + " was assigned to " + command.Channel.Mention + " by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/BlacklistCommand.cs b/SupportChild/Commands/BlacklistCommand.cs
index 5201ce2..dedf9ad 100644
--- a/SupportChild/Commands/BlacklistCommand.cs
+++ b/SupportChild/Commands/BlacklistCommand.cs
@@ -8,92 +8,92 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class BlacklistCommand : BaseCommandModule
- {
- [Command("blacklist")]
- [Description("Blacklists a user from opening tickets.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "blacklist"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the blacklist command but did not have permission.");
- return;
- }
+ public class BlacklistCommand : BaseCommandModule
+ {
+ [Command("blacklist")]
+ [Description("Blacklists a user from opening tickets.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "blacklist"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the blacklist command but did not have permission.");
+ return;
+ }
- string[] parsedArgs = Utilities.ParseIDs(command.RawArgumentString);
- foreach (string parsedArg in parsedArgs)
- {
- if (ulong.TryParse(parsedArg, out ulong userId))
- {
- DiscordUser blacklistedUser = null;
- try
- {
- blacklistedUser = await command.Client.GetUserAsync(userId);
- }
- catch (NotFoundException) { }
+ string[] parsedArgs = Utilities.ParseIDs(command.RawArgumentString);
+ foreach (string parsedArg in parsedArgs)
+ {
+ if (ulong.TryParse(parsedArg, out ulong userId))
+ {
+ DiscordUser blacklistedUser = null;
+ try
+ {
+ blacklistedUser = await command.Client.GetUserAsync(userId);
+ }
+ catch (NotFoundException) { }
- if (blacklistedUser == null)
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Could not find user."
- };
- await command.RespondAsync(message);
- continue;
- }
+ if (blacklistedUser == null)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Could not find user."
+ };
+ await command.RespondAsync(message);
+ continue;
+ }
- try
- {
- if (!Database.Blacklist(blacklistedUser.Id, command.User.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = blacklistedUser.Mention + " is already blacklisted."
- };
- await command.RespondAsync(error);
- continue;
- }
+ try
+ {
+ if (!Database.Blacklist(blacklistedUser.Id, command.User.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = blacklistedUser.Mention + " is already blacklisted."
+ };
+ await command.RespondAsync(error);
+ continue;
+ }
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Blacklisted " + blacklistedUser.Mention + "."
- };
- await command.RespondAsync(message);
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Blacklisted " + blacklistedUser.Mention + "."
+ };
+ await command.RespondAsync(message);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = blacklistedUser.Mention + " was blacklisted from opening tickets by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- catch (Exception)
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error occured while blacklisting " + blacklistedUser.Mention + "."
- };
- await command.RespondAsync(message);
- throw;
- }
- }
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = blacklistedUser.Mention + " was blacklisted from opening tickets by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ catch (Exception)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error occured while blacklisting " + blacklistedUser.Mention + "."
+ };
+ await command.RespondAsync(message);
+ throw;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/CloseCommand.cs b/SupportChild/Commands/CloseCommand.cs
index 9247425..51e5324 100644
--- a/SupportChild/Commands/CloseCommand.cs
+++ b/SupportChild/Commands/CloseCommand.cs
@@ -10,109 +10,109 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class CloseCommand : BaseCommandModule
- {
- [Command("close")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "close"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the close command but did not have permission.");
- return;
- }
+ public class CloseCommand : BaseCommandModule
+ {
+ [Command("close")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "close"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the close command but did not have permission.");
+ return;
+ }
- ulong channelID = command.Channel.Id;
- string channelName = command.Channel.Name;
+ ulong channelID = command.Channel.Id;
+ string channelName = command.Channel.Name;
- // Check if ticket exists in the database
- if (!Database.TryGetOpenTicket(channelID, out Database.Ticket ticket))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (!Database.TryGetOpenTicket(channelID, out Database.Ticket ticket))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- // Build transcript
- try
- {
- await Transcriber.ExecuteAsync(command.Channel.Id, ticket.id);
- }
- catch (Exception)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "ERROR: Could not save transcript file. Aborting..."
- };
- await command.RespondAsync(error);
- throw;
- }
+ // Build transcript
+ try
+ {
+ await Transcriber.ExecuteAsync(command.Channel.Id, ticket.id);
+ }
+ catch (Exception)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "ERROR: Could not save transcript file. Aborting..."
+ };
+ await command.RespondAsync(error);
+ throw;
+ }
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed embed = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket " + ticket.id.ToString("00000") + " closed by " + command.Member.Mention + ".\n",
- Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + channelName }
- };
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed embed = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket " + ticket.id.ToString("00000") + " closed by " + command.Member.Mention + ".\n",
+ Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + channelName }
+ };
- using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
- {
- DiscordMessageBuilder message = new DiscordMessageBuilder();
- message.WithEmbed(embed);
- message.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
+ using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
+ {
+ DiscordMessageBuilder message = new DiscordMessageBuilder();
+ message.WithEmbed(embed);
+ message.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
- await logChannel.SendMessageAsync(message);
- }
- }
+ await logChannel.SendMessageAsync(message);
+ }
+ }
- if (Config.closingNotifications)
- {
- DiscordEmbed embed = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket " + ticket.id.ToString("00000") + " which you opened has now been closed, check the transcript for more info.\n",
- Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + channelName }
- };
+ if (Config.closingNotifications)
+ {
+ DiscordEmbed embed = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket " + ticket.id.ToString("00000") + " which you opened has now been closed, check the transcript for more info.\n",
+ Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + channelName }
+ };
- try
- {
- DiscordMember staffMember = await command.Guild.GetMemberAsync(ticket.creatorID);
+ try
+ {
+ DiscordMember staffMember = await command.Guild.GetMemberAsync(ticket.creatorID);
- using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
- {
- DiscordMessageBuilder message = new DiscordMessageBuilder();
- message.WithEmbed(embed);
- message.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
+ using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
+ {
+ DiscordMessageBuilder message = new DiscordMessageBuilder();
+ message.WithEmbed(embed);
+ message.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
- await staffMember.SendMessageAsync(message);
- }
- }
- catch (NotFoundException) { }
- catch (UnauthorizedException) { }
- }
+ await staffMember.SendMessageAsync(message);
+ }
+ }
+ catch (NotFoundException) { }
+ catch (UnauthorizedException) { }
+ }
- Database.ArchiveTicket(ticket);
+ Database.ArchiveTicket(ticket);
- // Delete the channel and database entry
- await command.Channel.DeleteAsync("Ticket closed.");
+ // Delete the channel and database entry
+ await command.Channel.DeleteAsync("Ticket closed.");
- Database.DeleteOpenTicket(ticket.id);
- }
- }
-}
+ Database.DeleteOpenTicket(ticket.id);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/ListAssignedCommand.cs b/SupportChild/Commands/ListAssignedCommand.cs
index 1440dc7..351df6c 100644
--- a/SupportChild/Commands/ListAssignedCommand.cs
+++ b/SupportChild/Commands/ListAssignedCommand.cs
@@ -8,69 +8,69 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class ListAssignedCommand : BaseCommandModule
- {
- [Command("listassigned")]
- [Aliases("la")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "listassigned"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the listassigned command but did not have permission.");
- return;
- }
+ public class ListAssignedCommand : BaseCommandModule
+ {
+ [Command("listassigned")]
+ [Aliases("la")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "listassigned"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the listassigned command but did not have permission.");
+ return;
+ }
- ulong staffID;
- string[] parsedIDs = Utilities.ParseIDs(command.RawArgumentString);
+ ulong staffID;
+ string[] parsedIDs = Utilities.ParseIDs(command.RawArgumentString);
- if (!parsedIDs.Any())
- {
- staffID = command.Member.Id;
- }
- else if (!ulong.TryParse(parsedIDs[0], out staffID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!parsedIDs.Any())
+ {
+ staffID = command.Member.Id;
+ }
+ else if (!ulong.TryParse(parsedIDs[0], out staffID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (!Database.TryGetAssignedTickets(staffID, out List assignedTickets))
- {
- DiscordEmbed error = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Red)
- .WithDescription("User does not have any assigned tickets.");
- await command.RespondAsync(error);
- return;
- }
+ if (!Database.TryGetAssignedTickets(staffID, out List assignedTickets))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Red)
+ .WithDescription("User does not have any assigned tickets.");
+ await command.RespondAsync(error);
+ return;
+ }
- List listItems = new List();
- foreach (Database.Ticket ticket in assignedTickets)
- {
- listItems.Add("**" + ticket.FormattedCreatedTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n");
- }
+ List listItems = new List();
+ foreach (Database.Ticket ticket in assignedTickets)
+ {
+ listItems.Add("**" + ticket.FormattedCreatedTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n");
+ }
- LinkedList messages = Utilities.ParseListIntoMessages(listItems);
- foreach (string message in messages)
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithTitle("Assigned tickets: ")
- .WithColor(DiscordColor.Green)
- .WithDescription(message);
- await command.RespondAsync(channelInfo);
- }
+ LinkedList messages = Utilities.ParseListIntoMessages(listItems);
+ foreach (string message in messages)
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithTitle("Assigned tickets: ")
+ .WithColor(DiscordColor.Green)
+ .WithDescription(message);
+ await command.RespondAsync(channelInfo);
+ }
- }
- }
-}
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/ListCommand.cs b/SupportChild/Commands/ListCommand.cs
index 5a948e0..3916ed4 100644
--- a/SupportChild/Commands/ListCommand.cs
+++ b/SupportChild/Commands/ListCommand.cs
@@ -8,94 +8,94 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class ListCommand : BaseCommandModule
- {
- [Command("list")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "list"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the list command but did not have permission.");
- return;
- }
+ public class ListCommand : BaseCommandModule
+ {
+ [Command("list")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "list"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the list command but did not have permission.");
+ return;
+ }
- ulong userID;
- string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
+ ulong userID;
+ string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
- if (!parsedMessage.Any())
- {
- userID = command.Member.Id;
- }
- else if (!ulong.TryParse(parsedMessage[0], out userID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!parsedMessage.Any())
+ {
+ userID = command.Member.Id;
+ }
+ else if (!ulong.TryParse(parsedMessage[0], out userID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (Database.TryGetOpenTickets(userID, out List openTickets))
- {
- List listItems = new List();
- foreach (Database.Ticket ticket in openTickets)
- {
- listItems.Add("**" + ticket.FormattedCreatedTime() + ":** <#" + ticket.channelID + ">\n");
- }
+ if (Database.TryGetOpenTickets(userID, out List openTickets))
+ {
+ List listItems = new List();
+ foreach (Database.Ticket ticket in openTickets)
+ {
+ listItems.Add("**" + ticket.FormattedCreatedTime() + ":** <#" + ticket.channelID + ">\n");
+ }
- LinkedList messages = Utilities.ParseListIntoMessages(listItems);
- foreach (string message in messages)
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithTitle("Open tickets: ")
- .WithColor(DiscordColor.Green)
- .WithDescription(message);
- await command.RespondAsync(channelInfo);
- }
- }
- else
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Green)
- .WithDescription("User does not have any open tickets.");
- await command.RespondAsync(channelInfo);
- }
+ LinkedList messages = Utilities.ParseListIntoMessages(listItems);
+ foreach (string message in messages)
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithTitle("Open tickets: ")
+ .WithColor(DiscordColor.Green)
+ .WithDescription(message);
+ await command.RespondAsync(channelInfo);
+ }
+ }
+ else
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Green)
+ .WithDescription("User does not have any open tickets.");
+ await command.RespondAsync(channelInfo);
+ }
- if (Database.TryGetClosedTickets(userID, out List closedTickets))
- {
- List listItems = new List();
- foreach (Database.Ticket ticket in closedTickets)
- {
- listItems.Add("**" + ticket.FormattedCreatedTime() + ":** Ticket " + ticket.id.ToString("00000") + "\n");
- }
+ if (Database.TryGetClosedTickets(userID, out List closedTickets))
+ {
+ List listItems = new List();
+ foreach (Database.Ticket ticket in closedTickets)
+ {
+ listItems.Add("**" + ticket.FormattedCreatedTime() + ":** Ticket " + ticket.id.ToString("00000") + "\n");
+ }
- LinkedList messages = Utilities.ParseListIntoMessages(listItems);
- foreach (string message in messages)
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithTitle("Closed tickets: ")
- .WithColor(DiscordColor.Red)
- .WithDescription(message);
- await command.RespondAsync(channelInfo);
- }
- }
- else
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Red)
- .WithDescription("User does not have any closed tickets.");
- await command.RespondAsync(channelInfo);
- }
- }
- }
-}
+ LinkedList messages = Utilities.ParseListIntoMessages(listItems);
+ foreach (string message in messages)
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithTitle("Closed tickets: ")
+ .WithColor(DiscordColor.Red)
+ .WithDescription(message);
+ await command.RespondAsync(channelInfo);
+ }
+ }
+ else
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Red)
+ .WithDescription("User does not have any closed tickets.");
+ await command.RespondAsync(channelInfo);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/ListOldestCommand.cs b/SupportChild/Commands/ListOldestCommand.cs
index fbf5b3e..394b8d0 100644
--- a/SupportChild/Commands/ListOldestCommand.cs
+++ b/SupportChild/Commands/ListOldestCommand.cs
@@ -7,65 +7,65 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class ListOldestCommand : BaseCommandModule
- {
- [Command("listoldest")]
- [Aliases("lo")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "listoldest"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the listoldest command but did not have permission.");
- return;
- }
+ public class ListOldestCommand : BaseCommandModule
+ {
+ [Command("listoldest")]
+ [Aliases("lo")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "listoldest"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the listoldest command but did not have permission.");
+ return;
+ }
- int listLimit = 20;
- if (!string.IsNullOrEmpty(command.RawArgumentString?.Trim() ?? ""))
- {
- if (!int.TryParse(command.RawArgumentString?.Trim(), out listLimit) || listLimit < 5 || listLimit > 100)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid list amount. (Must be an integer between 5 and 100)"
- };
- await command.RespondAsync(error);
- return;
- }
- }
+ int listLimit = 20;
+ if (!string.IsNullOrEmpty(command.RawArgumentString?.Trim() ?? ""))
+ {
+ if (!int.TryParse(command.RawArgumentString?.Trim(), out listLimit) || listLimit < 5 || listLimit > 100)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid list amount. (Must be integer between 5 and 100)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
+ }
- if (!Database.TryGetOldestTickets(command.Member.Id, out List openTickets, listLimit))
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Red)
- .WithDescription("Could not fetch any open tickets.");
- await command.RespondAsync(channelInfo);
- return;
- }
+ if (!Database.TryGetOldestTickets(command.Member.Id, out List openTickets, listLimit))
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Red)
+ .WithDescription("Could not fetch any open tickets.");
+ await command.RespondAsync(channelInfo);
+ return;
+ }
- List listItems = new List();
- foreach (Database.Ticket ticket in openTickets)
- {
- listItems.Add("**" + ticket.FormattedCreatedTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n");
- }
+ List listItems = new List();
+ foreach (Database.Ticket ticket in openTickets)
+ {
+ listItems.Add("**" + ticket.FormattedCreatedTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n");
+ }
- LinkedList messages = Utilities.ParseListIntoMessages(listItems);
- foreach (string message in messages)
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithTitle("The " + openTickets.Count + " oldest open tickets: ")
- .WithColor(DiscordColor.Green)
- .WithDescription(message?.Trim());
- await command.RespondAsync(channelInfo);
- }
- }
- }
-}
+ LinkedList messages = Utilities.ParseListIntoMessages(listItems);
+ foreach (string message in messages)
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithTitle("The " + openTickets.Count + " oldest open tickets: ")
+ .WithColor(DiscordColor.Green)
+ .WithDescription(message?.Trim());
+ await command.RespondAsync(channelInfo);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/ListUnassignedCommand.cs b/SupportChild/Commands/ListUnassignedCommand.cs
index 4a787b5..19236cf 100644
--- a/SupportChild/Commands/ListUnassignedCommand.cs
+++ b/SupportChild/Commands/ListUnassignedCommand.cs
@@ -52,4 +52,4 @@ namespace SupportChild.Commands
}
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/MoveCommand.cs b/SupportChild/Commands/MoveCommand.cs
index cf2ef6a..4ef0737 100644
--- a/SupportChild/Commands/MoveCommand.cs
+++ b/SupportChild/Commands/MoveCommand.cs
@@ -10,95 +10,95 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class MoveCommand : BaseCommandModule
- {
- [Command("move")]
- [Description("Moves a ticket to another category.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "move"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the move command but did not have permission.");
- return;
- }
+ public class MoveCommand : BaseCommandModule
+ {
+ [Command("move")]
+ [Description("Moves a ticket to another category.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "move"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the move command but did not have permission.");
+ return;
+ }
- // Check if ticket exists in the database
- if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (string.IsNullOrEmpty(command.RawArgumentString))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: No category provided."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (string.IsNullOrEmpty(command.RawArgumentString))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: No category provided."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- IReadOnlyList channels = await command.Guild.GetChannelsAsync();
- IEnumerable categories = channels.Where(x => x.IsCategory);
- DiscordChannel category = categories.FirstOrDefault(x => x.Name.StartsWith(command.RawArgumentString.Trim(), StringComparison.OrdinalIgnoreCase));
+ IReadOnlyList channels = await command.Guild.GetChannelsAsync();
+ IEnumerable categories = channels.Where(x => x.IsCategory);
+ DiscordChannel category = categories.FirstOrDefault(x => x.Name.StartsWith(command.RawArgumentString.Trim(), StringComparison.OrdinalIgnoreCase));
- if (category == null)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Could not find a category by that name."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (category == null)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Could not find a category by that name."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (command.Channel.Id == category.Id)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: The ticket is already in that category."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (command.Channel.Id == category.Id)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: The ticket is already in that category."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- try
- {
- await command.Channel.ModifyAsync(modifiedAttributes => modifiedAttributes.Parent = category);
- }
- catch (UnauthorizedException)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Not authorized to move this ticket to that category."
- };
- await command.RespondAsync(error);
- return;
- }
+ try
+ {
+ await command.Channel.ModifyAsync(modifiedAttributes => modifiedAttributes.Parent = category);
+ }
+ catch (UnauthorizedException)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Not authorized to move this ticket to that category."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- DiscordEmbed feedback = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket was moved to " + category.Mention
- };
- await command.RespondAsync(feedback);
- }
- }
-}
+ DiscordEmbed feedback = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket was moved to " + category.Mention
+ };
+ await command.RespondAsync(feedback);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/NewCommand.cs b/SupportChild/Commands/NewCommand.cs
index 5f6fac9..1345a00 100644
--- a/SupportChild/Commands/NewCommand.cs
+++ b/SupportChild/Commands/NewCommand.cs
@@ -9,142 +9,142 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class NewCommand : BaseCommandModule
- {
- [Command("new")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "new"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the new command but did not have permission.");
- return;
- }
+ public class NewCommand : BaseCommandModule
+ {
+ [Command("new")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "new"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the new command but did not have permission.");
+ return;
+ }
- // Check if user is blacklisted
- if (Database.IsBlacklisted(command.User.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You are banned from opening tickets."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if user is blacklisted
+ if (Database.IsBlacklisted(command.User.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You are banned from opening tickets."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (Database.IsOpenTicket(command.Channel.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You cannot use this command in a ticket channel."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (Database.IsOpenTicket(command.Channel.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You cannot use this command in a ticket channel."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- DiscordChannel category = command.Guild.GetChannel(Config.ticketCategory);
- DiscordChannel ticketChannel;
+ DiscordChannel category = command.Guild.GetChannel(Config.ticketCategory);
+ DiscordChannel ticketChannel;
- try
- {
- ticketChannel = await command.Guild.CreateChannelAsync("ticket", ChannelType.Text, category);
- }
- catch (Exception)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error occured while creating ticket, " + command.Member.Mention +
- "!\nIs the channel limit reached in the server or ticket category?"
- };
- await command.RespondAsync(error);
- return;
- }
+ try
+ {
+ ticketChannel = await command.Guild.CreateChannelAsync("ticket", ChannelType.Text, category);
+ }
+ catch (Exception)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error occured while creating ticket, " + command.Member.Mention +
+ "!\nIs the channel limit reached in the server or ticket category?"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (ticketChannel == null)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error occured while creating ticket, " + command.Member.Mention +
- "!\nIs the channel limit reached in the server or ticket category?"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (ticketChannel == null)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error occured while creating ticket, " + command.Member.Mention +
+ "!\nIs the channel limit reached in the server or ticket category?"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- ulong staffID = 0;
- if (Config.randomAssignment)
- {
- staffID = Database.GetRandomActiveStaff(0)?.userID ?? 0;
- }
+ ulong staffID = 0;
+ if (Config.randomAssignment)
+ {
+ staffID = Database.GetRandomActiveStaff(0)?.userID ?? 0;
+ }
- long id = Database.NewTicket(command.Member.Id, staffID, ticketChannel.Id);
- string ticketID = id.ToString("00000");
- await ticketChannel.ModifyAsync(modifiedAttributes => modifiedAttributes.Name = "ticket-" + ticketID);
- await ticketChannel.AddOverwriteAsync(command.Member, Permissions.AccessChannels, Permissions.None);
+ long id = Database.NewTicket(command.Member.Id, staffID, ticketChannel.Id);
+ string ticketID = id.ToString("00000");
+ await ticketChannel.ModifyAsync(modifiedAttributes => modifiedAttributes.Name = "ticket-" + ticketID);
+ await ticketChannel.AddOverwriteAsync(command.Member, Permissions.AccessChannels, Permissions.None);
- await ticketChannel.SendMessageAsync("Hello, " + command.Member.Mention + "!\n" + Config.welcomeMessage);
+ await ticketChannel.SendMessageAsync("Hello, " + command.Member.Mention + "!\n" + Config.welcomeMessage);
- // Refreshes the channel as changes were made to it above
- ticketChannel = command.Guild.GetChannel(ticketChannel.Id);
+ // Refreshes the channel as changes were made to it above
+ ticketChannel = command.Guild.GetChannel(ticketChannel.Id);
- if (staffID != 0)
- {
- DiscordEmbed assignmentMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket was randomly assigned to <@" + staffID + ">."
- };
- await ticketChannel.SendMessageAsync(assignmentMessage);
+ if (staffID != 0)
+ {
+ DiscordEmbed assignmentMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket was randomly assigned to <@" + staffID + ">."
+ };
+ await ticketChannel.SendMessageAsync(assignmentMessage);
- if (Config.assignmentNotifications)
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "You have been randomly assigned to a newly opened support ticket: " +
- ticketChannel.Mention
- };
+ if (Config.assignmentNotifications)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "You have been randomly assigned to a newly opened support ticket: " +
+ ticketChannel.Mention
+ };
- try
- {
- DiscordMember staffMember = await command.Guild.GetMemberAsync(staffID);
- await staffMember.SendMessageAsync(message);
- }
- catch (NotFoundException) { }
- catch (UnauthorizedException) { }
- }
- }
+ try
+ {
+ DiscordMember staffMember = await command.Guild.GetMemberAsync(staffID);
+ await staffMember.SendMessageAsync(message);
+ }
+ catch (NotFoundException) {}
+ catch (UnauthorizedException) {}
+ }
+ }
- DiscordEmbed response = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket opened, " + command.Member.Mention + "!\n" + ticketChannel.Mention
- };
- await command.RespondAsync(response);
+ DiscordEmbed response = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket opened, " + command.Member.Mention + "!\n" + ticketChannel.Mention
+ };
+ await command.RespondAsync(response);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket " + ticketChannel.Mention + " opened by " + command.Member.Mention + ".\n",
- Footer = new DiscordEmbedBuilder.EmbedFooter { Text = "Ticket " + ticketID }
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket " + ticketChannel.Mention + " opened by " + command.Member.Mention + ".\n",
+ Footer = new DiscordEmbedBuilder.EmbedFooter {Text = "Ticket " + ticketID}
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/RandomAssignCommand.cs b/SupportChild/Commands/RandomAssignCommand.cs
index ef9ecb1..7b2a3e3 100644
--- a/SupportChild/Commands/RandomAssignCommand.cs
+++ b/SupportChild/Commands/RandomAssignCommand.cs
@@ -10,173 +10,173 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class RandomAssignCommand : BaseCommandModule
- {
- [Command("rassign")]
- [Description("Randomly assigns a staff member to a ticket.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArguments)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "rassign"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the rassign command but did not have permission.");
- return;
- }
+ public class RandomAssignCommand : BaseCommandModule
+ {
+ [Command("rassign")]
+ [Description("Randomly assigns a staff member to a ticket.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArguments)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "rassign"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the rassign command but did not have permission.");
+ return;
+ }
- // Check if ticket exists in the database
- if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- // Get a random staff member who is verified to have the correct role if applicable
- DiscordMember staffMember = await GetRandomVerifiedStaffMember(command, ticket);
- if (staffMember == null)
- {
- return;
- }
+ // Get a random staff member who is verified to have the correct role if applicable
+ DiscordMember staffMember = await GetRandomVerifiedStaffMember(command, ticket);
+ if (staffMember == null)
+ {
+ return;
+ }
- // Attempt to assign the staff member to the ticket
- if (!Database.AssignStaff(ticket, staffMember.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Failed to assign " + staffMember.Mention + " to ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Attempt to assign the staff member to the ticket
+ if (!Database.AssignStaff(ticket, staffMember.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Failed to assign " + staffMember.Mention + " to ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- // Respond that the command was successful
- DiscordEmbed feedback = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Randomly assigned " + staffMember.Mention + " to ticket."
- };
- await command.RespondAsync(feedback);
+ // Respond that the command was successful
+ DiscordEmbed feedback = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Randomly assigned " + staffMember.Mention + " to ticket."
+ };
+ await command.RespondAsync(feedback);
- // Send a notification to the staff member if applicable
- if (Config.assignmentNotifications)
- {
- try
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "You have been randomly assigned to a support ticket: " + command.Channel.Mention
- };
- await staffMember.SendMessageAsync(message);
- }
- catch (UnauthorizedException) { }
- }
+ // Send a notification to the staff member if applicable
+ if (Config.assignmentNotifications)
+ {
+ try
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "You have been randomly assigned to a support ticket: " + command.Channel.Mention
+ };
+ await staffMember.SendMessageAsync(message);
+ }
+ catch (UnauthorizedException) {}
+ }
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = staffMember.Mention + " was assigned to " + command.Channel.Mention + " by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = staffMember.Mention + " was assigned to " + command.Channel.Mention + " by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
- private async Task GetRandomVerifiedStaffMember(CommandContext command, Database.Ticket ticket)
- {
- if (command.RawArguments.Any()) // An argument was provided, check if this can be parsed into a role
- {
- ulong roleID = 0;
+ private async Task GetRandomVerifiedStaffMember(CommandContext command, Database.Ticket ticket)
+ {
+ if (command.RawArguments.Any()) // An argument was provided, check if this can be parsed into a role
+ {
+ ulong roleID = 0;
- // Try to parse either discord mention or ID
- string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
- if (!ulong.TryParse(parsedMessage[0], out roleID))
- {
- // Try to find role by name
- roleID = Utilities.GetRoleByName(command.Guild, command.RawArgumentString)?.Id ?? 0;
- }
+ // Try to parse either discord mention or ID
+ string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
+ if (!ulong.TryParse(parsedMessage[0], out roleID))
+ {
+ // Try to find role by name
+ roleID = Utilities.GetRoleByName(command.Guild, command.RawArgumentString)?.Id ?? 0;
+ }
- // Check if a role was found
- if (roleID == 0)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Could not find a role by that name/ID."
- };
- await command.RespondAsync(error);
- return null;
- }
+ // Check if a role was found
+ if (roleID == 0)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Could not find a role by that name/ID."
+ };
+ await command.RespondAsync(error);
+ return null;
+ }
- // Check if role rassign should override staff's active status
- List staffMembers = Config.randomAssignRoleOverride
- ? Database.GetAllStaff(ticket.assignedStaffID)
- : Database.GetActiveStaff(ticket.assignedStaffID);
+ // Check if role rassign should override staff's active status
+ List staffMembers = Config.randomAssignRoleOverride
+ ? Database.GetAllStaff(ticket.assignedStaffID)
+ : Database.GetActiveStaff(ticket.assignedStaffID);
- // Randomize the list before checking for roles in order to reduce number of API calls
- staffMembers = Utilities.RandomizeList(staffMembers);
+ // Randomize the list before checking for roles in order to reduce number of API calls
+ staffMembers = Utilities.RandomizeList(staffMembers);
- // Get the first staff member that has the role
- foreach (Database.StaffMember sm in staffMembers)
- {
- try
- {
- DiscordMember verifiedMember = await command.Guild.GetMemberAsync(sm.userID);
- if (verifiedMember?.Roles?.Any(role => role.Id == roleID) ?? false)
- {
- return verifiedMember;
- }
- }
- catch (Exception e)
- {
- command.Client.Logger.Log(LogLevel.Information, e, "Error occured trying to find a staff member in the rassign command.");
- }
- }
- }
- else // No role was specified, any active staff will be picked
- {
- Database.StaffMember staffEntry = Database.GetRandomActiveStaff(ticket.assignedStaffID);
- if (staffEntry == null)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: There are no other staff members to choose from."
- };
- await command.RespondAsync(error);
- return null;
- }
+ // Get the first staff member that has the role
+ foreach (Database.StaffMember sm in staffMembers)
+ {
+ try
+ {
+ DiscordMember verifiedMember = await command.Guild.GetMemberAsync(sm.userID);
+ if (verifiedMember?.Roles?.Any(role => role.Id == roleID) ?? false)
+ {
+ return verifiedMember;
+ }
+ }
+ catch (Exception e)
+ {
+ command.Client.Logger.Log(LogLevel.Information, e, "Error occured trying to find a staff member in the rassign command.");
+ }
+ }
+ }
+ else // No role was specified, any active staff will be picked
+ {
+ Database.StaffMember staffEntry = Database.GetRandomActiveStaff(ticket.assignedStaffID);
+ if (staffEntry == null)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: There are no other staff members to choose from."
+ };
+ await command.RespondAsync(error);
+ return null;
+ }
- // Get the staff member from discord
- try
- {
- return await command.Guild.GetMemberAsync(staffEntry.userID);
- }
- catch (NotFoundException) { }
- }
+ // Get the staff member from discord
+ try
+ {
+ return await command.Guild.GetMemberAsync(staffEntry.userID);
+ }
+ catch (NotFoundException) { }
+ }
- // Send a more generic error if we get to this point and still haven't found the staff member
- DiscordEmbed err = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Could not find an applicable staff member."
- };
- await command.RespondAsync(err);
- return null;
- }
- }
-}
+ // Send a more generic error if we get to this point and still haven't found the staff member
+ DiscordEmbed err = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Could not find an applicable staff member."
+ };
+ await command.RespondAsync(err);
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/ReloadCommand.cs b/SupportChild/Commands/ReloadCommand.cs
index 7ea95b1..de426c0 100644
--- a/SupportChild/Commands/ReloadCommand.cs
+++ b/SupportChild/Commands/ReloadCommand.cs
@@ -35,4 +35,4 @@ namespace SupportChild.Commands
SupportChild.instance.Reload();
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/RemoveMessageCommand.cs b/SupportChild/Commands/RemoveMessageCommand.cs
index 37a5b9e..96794e4 100644
--- a/SupportChild/Commands/RemoveMessageCommand.cs
+++ b/SupportChild/Commands/RemoveMessageCommand.cs
@@ -40,7 +40,7 @@ namespace SupportChild.Commands
return;
}
- if (Database.RemoveMessage(identifier))
+ if(Database.RemoveMessage(identifier))
{
DiscordEmbed error = new DiscordEmbedBuilder
{
@@ -63,4 +63,4 @@ namespace SupportChild.Commands
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/RemoveStaffCommand.cs b/SupportChild/Commands/RemoveStaffCommand.cs
index 9f088e3..a48f96f 100644
--- a/SupportChild/Commands/RemoveStaffCommand.cs
+++ b/SupportChild/Commands/RemoveStaffCommand.cs
@@ -9,96 +9,96 @@ using MySql.Data.MySqlClient;
namespace SupportChild.Commands
{
- public class RemoveStaffCommand : BaseCommandModule
- {
- [Command("removestaff")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "removestaff"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the removestaff command but did not have permission.");
- return;
- }
+ public class RemoveStaffCommand : BaseCommandModule
+ {
+ [Command("removestaff")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "removestaff"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the removestaff command but did not have permission.");
+ return;
+ }
- ulong userID;
- string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
+ ulong userID;
+ string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
- if (!parsedMessage.Any())
- {
- userID = command.Member.Id;
- }
- else if (!ulong.TryParse(parsedMessage[0], out userID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!parsedMessage.Any())
+ {
+ userID = command.Member.Id;
+ }
+ else if (!ulong.TryParse(parsedMessage[0], out userID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- try
- {
- await command.Client.GetUserAsync(userID);
- }
- catch (Exception)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not find user on Discord)"
- };
- await command.RespondAsync(error);
- return;
- }
+ try
+ {
+ await command.Client.GetUserAsync(userID);
+ }
+ catch (Exception)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not find user on Discord)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- if (!Database.IsStaff(userID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "User is already not registered as staff."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!Database.IsStaff(userID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "User is already not registered as staff."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- using (MySqlConnection c = Database.GetConnection())
- {
- c.Open();
- MySqlCommand deletion = new MySqlCommand(@"DELETE FROM staff WHERE user_id=@user_id", c);
- deletion.Parameters.AddWithValue("@user_id", userID);
- deletion.Prepare();
- deletion.ExecuteNonQuery();
+ using (MySqlConnection c = Database.GetConnection())
+ {
+ c.Open();
+ MySqlCommand deletion = new MySqlCommand(@"DELETE FROM staff WHERE user_id=@user_id", c);
+ deletion.Parameters.AddWithValue("@user_id", userID);
+ deletion.Prepare();
+ deletion.ExecuteNonQuery();
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "User was removed from staff."
- };
- await command.RespondAsync(message);
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "User was removed from staff."
+ };
+ await command.RespondAsync(message);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "User was removed from staff.\n",
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "User was removed from staff.\n",
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/SayCommand.cs b/SupportChild/Commands/SayCommand.cs
index 897284b..5eaedd1 100644
--- a/SupportChild/Commands/SayCommand.cs
+++ b/SupportChild/Commands/SayCommand.cs
@@ -8,89 +8,89 @@ using System.Threading.Tasks;
namespace SupportChild.Commands
{
- public class SayCommand : BaseCommandModule
- {
- [Command("say")]
- [Cooldown(1, 2, CooldownBucketType.Channel)]
- [Description("Prints a message with information from staff.")]
- public async Task OnExecute(CommandContext command, string identifier)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "say"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the say command but did not have permission.");
- return;
- }
+ public class SayCommand : BaseCommandModule
+ {
+ [Command("say")]
+ [Cooldown(1, 2, CooldownBucketType.Channel)]
+ [Description("Prints a message with information from staff.")]
+ public async Task OnExecute(CommandContext command, string identifier)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "say"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the say command but did not have permission.");
+ return;
+ }
- if (!Database.TryGetMessage(identifier.ToLower(), out Database.Message message))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "There is no message with that identifier."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!Database.TryGetMessage(identifier.ToLower(), out Database.Message message))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "There is no message with that identifier."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- DiscordEmbed reply = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = message.message
- };
- await command.RespondAsync(reply);
- }
+ DiscordEmbed reply = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = message.message
+ };
+ await command.RespondAsync(reply);
+ }
- [Command("say")]
- [Cooldown(1, 2.0, CooldownBucketType.Channel)]
- [Description("Prints a list of staff messages.")]
- public async Task OnExecute(CommandContext command)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "say"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the say command but did not have permission.");
- return;
- }
+ [Command("say")]
+ [Cooldown(1, 2.0, CooldownBucketType.Channel)]
+ [Description("Prints a list of staff messages.")]
+ public async Task OnExecute(CommandContext command)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "say"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the say command but did not have permission.");
+ return;
+ }
- List messages = Database.GetAllMessages();
- if (!messages.Any())
- {
- DiscordEmbed error = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Red)
- .WithDescription("There are no messages registered.");
- await command.RespondAsync(error);
- return;
- }
+ List messages = Database.GetAllMessages();
+ if (!messages.Any())
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Red)
+ .WithDescription("There are no messages registered.");
+ await command.RespondAsync(error);
+ return;
+ }
- List listItems = new List();
- foreach (Database.Message message in messages)
- {
- listItems.Add("**" + message.identifier + "** Added by <@" + message.userID + ">\n");
- }
+ List listItems = new List();
+ foreach (Database.Message message in messages)
+ {
+ listItems.Add("**" + message.identifier + "** Added by <@" + message.userID + ">\n");
+ }
- LinkedList listMessages = Utilities.ParseListIntoMessages(listItems);
- foreach (string listMessage in listMessages)
- {
- DiscordEmbed channelInfo = new DiscordEmbedBuilder()
- .WithTitle("Available messages: ")
- .WithColor(DiscordColor.Green)
- .WithDescription(listMessage);
- await command.RespondAsync(channelInfo);
- }
- }
- }
-}
+ LinkedList listMessages = Utilities.ParseListIntoMessages(listItems);
+ foreach (string listMessage in listMessages)
+ {
+ DiscordEmbed channelInfo = new DiscordEmbedBuilder()
+ .WithTitle("Available messages: ")
+ .WithColor(DiscordColor.Green)
+ .WithDescription(listMessage);
+ await command.RespondAsync(channelInfo);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/SetSummaryCommand.cs b/SupportChild/Commands/SetSummaryCommand.cs
index 2582833..81b0ca5 100644
--- a/SupportChild/Commands/SetSummaryCommand.cs
+++ b/SupportChild/Commands/SetSummaryCommand.cs
@@ -60,4 +60,4 @@ namespace SupportChild.Commands
}
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/SetTicketCommand.cs b/SupportChild/Commands/SetTicketCommand.cs
index a197020..11797ec 100644
--- a/SupportChild/Commands/SetTicketCommand.cs
+++ b/SupportChild/Commands/SetTicketCommand.cs
@@ -8,91 +8,91 @@ using MySql.Data.MySqlClient;
namespace SupportChild.Commands
{
- public class SetTicketCommand : BaseCommandModule
- {
- [Command("setticket")]
- [Description("Turns a channel into a ticket, warning: this will let anyone with write access delete the channel using the close command.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- using (MySqlConnection c = Database.GetConnection())
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "setticket"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the setticket command but did not have permission.");
- return;
- }
+ public class SetTicketCommand :BaseCommandModule
+ {
+ [Command("setticket")]
+ [Description("Turns a channel into a ticket, warning: this will let anyone with write access delete the channel using the close command.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ using (MySqlConnection c = Database.GetConnection())
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "setticket"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the setticket command but did not have permission.");
+ return;
+ }
- // Check if ticket exists in the database
- if (Database.IsOpenTicket(command.Channel.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is already a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (Database.IsOpenTicket(command.Channel.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is already a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- ulong userID;
- string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
+ ulong userID;
+ string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
- if (!parsedMessage.Any())
- {
- userID = command.Member.Id;
- }
- else if (!ulong.TryParse(parsedMessage[0], out userID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!parsedMessage.Any())
+ {
+ userID = command.Member.Id;
+ }
+ else if (!ulong.TryParse(parsedMessage[0], out userID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- DiscordUser user = await command.Client.GetUserAsync(userID);
+ DiscordUser user = await command.Client.GetUserAsync(userID);
- if (user == null)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention."
- };
- await command.RespondAsync(error);
- return;
- }
+ if (user == null)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- long id = Database.NewTicket(userID, 0, command.Channel.Id);
- string ticketID = id.ToString("00000");
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Channel has been designated ticket " + ticketID + "."
- };
- await command.RespondAsync(message);
+ long id = Database.NewTicket(userID, 0, command.Channel.Id);
+ string ticketID = id.ToString("00000");
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Channel has been designated ticket " + ticketID + "."
+ };
+ await command.RespondAsync(message);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = command.Channel.Mention + " has been designated ticket " + ticketID + " by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = command.Channel.Mention + " has been designated ticket " + ticketID + " by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/StatusCommand.cs b/SupportChild/Commands/StatusCommand.cs
index e715416..8521b80 100644
--- a/SupportChild/Commands/StatusCommand.cs
+++ b/SupportChild/Commands/StatusCommand.cs
@@ -38,4 +38,4 @@ namespace SupportChild.Commands
await command.RespondAsync(botInfo);
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/SummaryCommand.cs b/SupportChild/Commands/SummaryCommand.cs
index 660b458..360db00 100644
--- a/SupportChild/Commands/SummaryCommand.cs
+++ b/SupportChild/Commands/SummaryCommand.cs
@@ -48,4 +48,4 @@ namespace SupportChild.Commands
}
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/ToggleActiveCommand.cs b/SupportChild/Commands/ToggleActiveCommand.cs
index 4339267..b953367 100644
--- a/SupportChild/Commands/ToggleActiveCommand.cs
+++ b/SupportChild/Commands/ToggleActiveCommand.cs
@@ -8,71 +8,71 @@ using MySql.Data.MySqlClient;
namespace SupportChild.Commands
{
- public class ToggleActiveCommand : BaseCommandModule
- {
- [Command("toggleactive")]
- [Aliases("ta")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- using (MySqlConnection c = Database.GetConnection())
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "toggleactive"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the toggleactive command but did not have permission.");
- return;
- }
+ public class ToggleActiveCommand : BaseCommandModule
+ {
+ [Command("toggleactive")]
+ [Aliases("ta")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ using (MySqlConnection c = Database.GetConnection())
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "toggleactive"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the toggleactive command but did not have permission.");
+ return;
+ }
- ulong staffID;
- string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
+ ulong staffID;
+ string[] parsedMessage = Utilities.ParseIDs(command.RawArgumentString);
- if (!parsedMessage.Any())
- {
- staffID = command.Member.Id;
- }
- else if (!ulong.TryParse(parsedMessage[0], out staffID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Invalid ID/Mention. (Could not convert to numerical)"
- };
- await command.RespondAsync(error);
- return;
- }
+ if (!parsedMessage.Any())
+ {
+ staffID = command.Member.Id;
+ }
+ else if (!ulong.TryParse(parsedMessage[0], out staffID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Invalid ID/Mention. (Could not convert to numerical)"
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- // Check if ticket exists in the database
- if (!Database.TryGetStaff(staffID, out Database.StaffMember staffMember))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You have not been registered as staff."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (!Database.TryGetStaff(staffID, out Database.StaffMember staffMember))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You have not been registered as staff."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- c.Open();
- MySqlCommand update = new MySqlCommand(@"UPDATE staff SET active = @active WHERE user_id = @user_id", c);
- update.Parameters.AddWithValue("@user_id", staffID);
- update.Parameters.AddWithValue("@active", !staffMember.active);
- update.Prepare();
- update.ExecuteNonQuery();
+ c.Open();
+ MySqlCommand update = new MySqlCommand(@"UPDATE staff SET active = @active WHERE user_id = @user_id", c);
+ update.Parameters.AddWithValue("@user_id", staffID);
+ update.Parameters.AddWithValue("@active", !staffMember.active);
+ update.Prepare();
+ update.ExecuteNonQuery();
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = staffMember.active ? "Staff member is now set as inactive and will no longer be randomly assigned any support tickets." : "Staff member is now set as active and will be randomly assigned support tickets again."
- };
- await command.RespondAsync(message);
- }
- }
- }
-}
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = staffMember.active ? "Staff member is now set as inactive and will no longer be randomly assigned any support tickets." : "Staff member is now set as active and will be randomly assigned support tickets again."
+ };
+ await command.RespondAsync(message);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/TranscriptCommand.cs b/SupportChild/Commands/TranscriptCommand.cs
index 766261b..8fb24cd 100644
--- a/SupportChild/Commands/TranscriptCommand.cs
+++ b/SupportChild/Commands/TranscriptCommand.cs
@@ -10,163 +10,163 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class TranscriptCommand : BaseCommandModule
- {
- [Command("transcript")]
- [Cooldown(1, 5, CooldownBucketType.User)]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "transcript"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the transcript command but did not have permission.");
- return;
- }
+ public class TranscriptCommand : BaseCommandModule
+ {
+ [Command("transcript")]
+ [Cooldown(1, 5, CooldownBucketType.User)]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "transcript"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the transcript command but did not have permission.");
+ return;
+ }
- Database.Ticket ticket;
- string strippedMessage = command.Message.Content.Replace(Config.prefix, "");
- string[] parsedMessage = strippedMessage.Replace("<@!", "").Replace("<@", "").Replace(">", "").Split();
+ Database.Ticket ticket;
+ string strippedMessage = command.Message.Content.Replace(Config.prefix, "");
+ string[] parsedMessage = strippedMessage.Replace("<@!", "").Replace("<@", "").Replace(">", "").Split();
- // If there are no arguments use current channel
- if (parsedMessage.Length < 2)
- {
- if (Database.TryGetOpenTicket(command.Channel.Id, out ticket))
- {
- try
- {
- await Transcriber.ExecuteAsync(command.Channel.Id, ticket.id);
- }
- catch (Exception)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "ERROR: Could not save transcript file. Aborting..."
- };
- await command.RespondAsync(error);
- throw;
- }
- }
- else
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
- }
- else
- {
- // Check if argument is numerical, if not abort
- if (!uint.TryParse(parsedMessage[1], out uint ticketID))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Argument must be a number."
- };
- await command.RespondAsync(error);
- return;
- }
+ // If there are no arguments use current channel
+ if (parsedMessage.Length < 2)
+ {
+ if (Database.TryGetOpenTicket(command.Channel.Id, out ticket))
+ {
+ try
+ {
+ await Transcriber.ExecuteAsync(command.Channel.Id, ticket.id);
+ }
+ catch (Exception)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "ERROR: Could not save transcript file. Aborting..."
+ };
+ await command.RespondAsync(error);
+ throw;
+ }
+ }
+ else
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
+ }
+ else
+ {
+ // Check if argument is numerical, if not abort
+ if (!uint.TryParse(parsedMessage[1], out uint ticketID))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Argument must be a number."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- // If the ticket is still open, generate a new fresh transcript
- if (Database.TryGetOpenTicketByID(ticketID, out ticket) && ticket?.creatorID == command.Member.Id)
- {
- try
- {
- await Transcriber.ExecuteAsync(command.Channel.Id, ticket.id);
- }
- catch (Exception)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "ERROR: Could not save transcript file. Aborting..."
- };
- await command.RespondAsync(error);
- throw;
- }
+ // If the ticket is still open, generate a new fresh transcript
+ if (Database.TryGetOpenTicketByID(ticketID, out ticket) && ticket?.creatorID == command.Member.Id)
+ {
+ try
+ {
+ await Transcriber.ExecuteAsync(command.Channel.Id, ticket.id);
+ }
+ catch (Exception)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "ERROR: Could not save transcript file. Aborting..."
+ };
+ await command.RespondAsync(error);
+ throw;
+ }
- }
- // If there is no open or closed ticket, send an error. If there is a closed ticket we will simply use the old transcript from when the ticket was closed.
- else if (!Database.TryGetClosedTicket(ticketID, out ticket) || ticket?.creatorID != command.Member.Id && !Database.IsStaff(command.Member.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Could not find a closed ticket with that number which you opened." + (Config.HasPermission(command.Member, "list") ? "\n(Use the " + Config.prefix + "list command to see all your tickets)" : "")
- };
- await command.RespondAsync(error);
- return;
- }
- }
+ }
+ // If there is no open or closed ticket, send an error. If there is a closed ticket we will simply use the old transcript from when the ticket was closed.
+ else if (!Database.TryGetClosedTicket(ticketID, out ticket) || (ticket?.creatorID != command.Member.Id && !Database.IsStaff(command.Member.Id)))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Could not find a closed ticket with that number which you opened." + (Config.HasPermission(command.Member, "list") ? "\n(Use the " + Config.prefix + "list command to see all your tickets)" : "")
+ };
+ await command.RespondAsync(error);
+ return;
+ }
+ }
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed embed = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket " + ticket.id.ToString("00000") + " transcript generated by " + command.Member.Mention + ".\n",
- Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + command.Channel.Name }
- };
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed embed = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket " + ticket.id.ToString("00000") + " transcript generated by " + command.Member.Mention + ".\n",
+ Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + command.Channel.Name }
+ };
- using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
- {
- DiscordMessageBuilder message = new DiscordMessageBuilder();
- message.WithEmbed(embed);
- message.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
+ using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
+ {
+ DiscordMessageBuilder message = new DiscordMessageBuilder();
+ message.WithEmbed(embed);
+ message.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
- await logChannel.SendMessageAsync(message);
- }
- }
+ await logChannel.SendMessageAsync(message);
+ }
+ }
- try
- {
- // Send transcript privately
- DiscordEmbed directMessageEmbed = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Transcript generated, " + command.Member.Mention + "!\n"
- };
+ try
+ {
+ // Send transcript privately
+ DiscordEmbed directMessageEmbed = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Transcript generated, " + command.Member.Mention + "!\n"
+ };
- using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
- {
- DiscordMessageBuilder directMessage = new DiscordMessageBuilder();
- directMessage.WithEmbed(directMessageEmbed);
- directMessage.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
+ using (FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read))
+ {
+ DiscordMessageBuilder directMessage = new DiscordMessageBuilder();
+ directMessage.WithEmbed(directMessageEmbed);
+ directMessage.WithFiles(new Dictionary() { { Transcriber.GetFilename(ticket.id), file } });
- await command.Member.SendMessageAsync(directMessage);
- }
+ await command.Member.SendMessageAsync(directMessage);
+ }
- // Respond to message directly
- DiscordEmbed response = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Transcript sent, " + command.Member.Mention + "!\n"
- };
- await command.RespondAsync(response);
- }
- catch (UnauthorizedException)
- {
- // Send transcript privately
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Not allowed to send direct message to you, " + command.Member.Mention + ", please check your privacy settings.\n"
- };
- await command.RespondAsync(error);
- }
- }
- }
-}
+ // Respond to message directly
+ DiscordEmbed response = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Transcript sent, " + command.Member.Mention + "!\n"
+ };
+ await command.RespondAsync(response);
+ }
+ catch (UnauthorizedException)
+ {
+ // Send transcript privately
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Not allowed to send direct message to you, " + command.Member.Mention + ", please check your privacy settings.\n"
+ };
+ await command.RespondAsync(error);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/UnassignComand.cs b/SupportChild/Commands/UnassignComand.cs
new file mode 100644
index 0000000..5b892a8
--- /dev/null
+++ b/SupportChild/Commands/UnassignComand.cs
@@ -0,0 +1,71 @@
+using System.Threading.Tasks;
+using DSharpPlus.CommandsNext;
+using DSharpPlus.CommandsNext.Attributes;
+using DSharpPlus.Entities;
+using Microsoft.Extensions.Logging;
+
+namespace SupportChild.Commands
+{
+ public class UnassignCommand : BaseCommandModule
+ {
+ [Command("unassign")]
+ [Description("Unassigns a staff member from a ticket.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "unassign"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the unassign command but did not have permission.");
+ return;
+ }
+
+ // Check if ticket exists in the database
+ if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
+
+ if (!Database.UnassignStaff(ticket))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Failed to unassign staff from ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
+
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Unassigned staff from ticket."
+ };
+ await command.RespondAsync(message);
+
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Staff was unassigned from " + command.Channel.Mention + " by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/UnassignCommand.cs b/SupportChild/Commands/UnassignCommand.cs
deleted file mode 100644
index 3b31dbc..0000000
--- a/SupportChild/Commands/UnassignCommand.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using System.Threading.Tasks;
-using DSharpPlus.CommandsNext;
-using DSharpPlus.CommandsNext.Attributes;
-using DSharpPlus.Entities;
-using Microsoft.Extensions.Logging;
-
-namespace SupportChild.Commands
-{
- public class UnassignCommand : BaseCommandModule
- {
- [Command("unassign")]
- [Description("Unassigns a staff member from a ticket.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "unassign"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the unassign command but did not have permission.");
- return;
- }
-
- // Check if ticket exists in the database
- if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
-
- if (!Database.UnassignStaff(ticket))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Failed to unassign staff from ticket."
- };
- await command.RespondAsync(error);
- return;
- }
-
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Unassigned staff from ticket."
- };
- await command.RespondAsync(message);
-
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Staff was unassigned from " + command.Channel.Mention + " by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- }
-}
diff --git a/SupportChild/Commands/UnblacklistCommand.cs b/SupportChild/Commands/UnblacklistCommand.cs
index 577aa42..e73e5b3 100644
--- a/SupportChild/Commands/UnblacklistCommand.cs
+++ b/SupportChild/Commands/UnblacklistCommand.cs
@@ -8,92 +8,92 @@ using Microsoft.Extensions.Logging;
namespace SupportChild.Commands
{
- public class UnblacklistCommand : BaseCommandModule
- {
- [Command("unblacklist")]
- [Description("Un-blacklists a user from opening tickets.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "unblacklist"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the unblacklist command but did not have permission.");
- return;
- }
+ public class UnblacklistCommand : BaseCommandModule
+ {
+ [Command("unblacklist")]
+ [Description("Un-blacklists a user from opening tickets.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "unblacklist"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the unblacklist command but did not have permission.");
+ return;
+ }
- string[] words = Utilities.ParseIDs(command.RawArgumentString);
- foreach (string word in words)
- {
- if (ulong.TryParse(word, out ulong userId))
- {
- DiscordUser blacklistedUser = null;
- try
- {
- blacklistedUser = await command.Client.GetUserAsync(userId);
- }
- catch (NotFoundException) { }
+ string[] words = Utilities.ParseIDs(command.RawArgumentString);
+ foreach (string word in words)
+ {
+ if (ulong.TryParse(word, out ulong userId))
+ {
+ DiscordUser blacklistedUser = null;
+ try
+ {
+ blacklistedUser = await command.Client.GetUserAsync(userId);
+ }
+ catch (NotFoundException) { }
- if (blacklistedUser == null)
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error: Could not find user."
- };
- await command.RespondAsync(message);
- continue;
- }
+ if (blacklistedUser == null)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error: Could not find user."
+ };
+ await command.RespondAsync(message);
+ continue;
+ }
- try
- {
- if (!Database.Unblacklist(blacklistedUser.Id))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = blacklistedUser.Mention + " is not blacklisted."
- };
- await command.RespondAsync(error);
- continue;
- }
+ try
+ {
+ if (!Database.Unblacklist(blacklistedUser.Id))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = blacklistedUser.Mention + " is not blacklisted."
+ };
+ await command.RespondAsync(error);
+ continue;
+ }
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Removed " + blacklistedUser.Mention + " from blacklist."
- };
- await command.RespondAsync(message);
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Removed " + blacklistedUser.Mention + " from blacklist."
+ };
+ await command.RespondAsync(message);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = blacklistedUser.Mention + " was unblacklisted from opening tickets by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- catch (Exception)
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Error occured while removing " + blacklistedUser.Mention + " from blacklist."
- };
- await command.RespondAsync(message);
- throw;
- }
- }
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = blacklistedUser.Mention + " was unblacklisted from opening tickets by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ catch (Exception)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Error occured while removing " + blacklistedUser.Mention + " from blacklist."
+ };
+ await command.RespondAsync(message);
+ throw;
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Commands/UnsetTicketCommand.cs b/SupportChild/Commands/UnsetTicketCommand.cs
index 1c49975..1ead160 100644
--- a/SupportChild/Commands/UnsetTicketCommand.cs
+++ b/SupportChild/Commands/UnsetTicketCommand.cs
@@ -7,64 +7,64 @@ using MySql.Data.MySqlClient;
namespace SupportChild.Commands
{
- public class UnsetTicketCommand : BaseCommandModule
- {
- [Command("unsetticket")]
- [Description(
- "Deletes a channel from the ticket system without deleting the channel.")]
- public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
- {
- using (MySqlConnection c = Database.GetConnection())
- {
- // Check if the user has permission to use this command.
- if (!Config.HasPermission(command.Member, "unsetticket"))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "You do not have permission to use this command."
- };
- await command.RespondAsync(error);
- command.Client.Logger.Log(LogLevel.Information, "User tried to use the unsetticket command but did not have permission.");
- return;
- }
+ public class UnsetTicketCommand : BaseCommandModule
+ {
+ [Command("unsetticket")]
+ [Description(
+ "Deletes a channel from the ticket system without deleting the channel.")]
+ public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
+ {
+ using (MySqlConnection c = Database.GetConnection())
+ {
+ // Check if the user has permission to use this command.
+ if (!Config.HasPermission(command.Member, "unsetticket"))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "You do not have permission to use this command."
+ };
+ await command.RespondAsync(error);
+ command.Client.Logger.Log(LogLevel.Information, "User tried to use the unsetticket command but did not have permission.");
+ return;
+ }
- // Check if ticket exists in the database
- if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "This channel is not a ticket."
- };
- await command.RespondAsync(error);
- return;
- }
+ // Check if ticket exists in the database
+ if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket))
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "This channel is not a ticket."
+ };
+ await command.RespondAsync(error);
+ return;
+ }
- c.Open();
- MySqlCommand deletion = new MySqlCommand(@"DELETE FROM tickets WHERE channel_id=@channel_id", c);
- deletion.Parameters.AddWithValue("@channel_id", command.Channel.Id);
- deletion.Prepare();
- deletion.ExecuteNonQuery();
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Channel has been undesignated as a ticket."
- };
- await command.RespondAsync(message);
+ c.Open();
+ MySqlCommand deletion = new MySqlCommand(@"DELETE FROM tickets WHERE channel_id=@channel_id", c);
+ deletion.Parameters.AddWithValue("@channel_id", command.Channel.Id);
+ deletion.Prepare();
+ deletion.ExecuteNonQuery();
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Channel has been undesignated as a ticket."
+ };
+ await command.RespondAsync(message);
- // Log it if the log channel exists
- DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = command.Channel.Mention + " has been undesignated as a ticket by " + command.Member.Mention + "."
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
- }
- }
-}
+ // Log it if the log channel exists
+ DiscordChannel logChannel = command.Guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = command.Channel.Mention + " has been undesignated as a ticket by " + command.Member.Mention + "."
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Config.cs b/SupportChild/Config.cs
index 7682597..858e17b 100644
--- a/SupportChild/Config.cs
+++ b/SupportChild/Config.cs
@@ -10,134 +10,134 @@ using YamlDotNet.Serialization;
namespace SupportChild
{
- internal static class Config
- {
- internal static string token = "";
- internal static string prefix = "";
- internal static ulong logChannel;
- internal static ulong ticketCategory;
- internal static ulong reactionMessage;
- internal static string welcomeMessage = "";
- internal static string logLevel = "Information";
- internal static string timestampFormat = "yyyy-MMM-dd HH:mm";
- internal static bool randomAssignment = false;
- internal static bool randomAssignRoleOverride = false; // TODO: Implement
- internal static string presenceType = "Playing";
- internal static string presenceText = "";
+ internal static class Config
+ {
+ internal static string token = "";
+ internal static string prefix = "";
+ internal static ulong logChannel;
+ internal static ulong ticketCategory;
+ internal static ulong reactionMessage;
+ internal static string welcomeMessage = "";
+ internal static string logLevel = "Information";
+ internal static string timestampFormat = "yyyy-MMM-dd HH:mm";
+ internal static bool randomAssignment = false;
+ internal static bool randomAssignRoleOverride = false;
+ internal static string presenceType = "Playing";
+ internal static string presenceText = "";
- internal static bool ticketUpdatedNotifications = false;
- internal static double ticketUpdatedNotificationDelay = 0.0;
- internal static bool assignmentNotifications = false;
- internal static bool closingNotifications = false;
+ internal static bool ticketUpdatedNotifications = false;
+ internal static double ticketUpdatedNotificationDelay = 0.0;
+ internal static bool assignmentNotifications = false;
+ internal static bool closingNotifications = false;
- internal static string hostName = "127.0.0.1";
- internal static int port = 3306;
- internal static string database = "supportbot";
- internal static string username = "supportbot";
- internal static string password = "";
+ internal static string hostName = "127.0.0.1";
+ internal static int port = 3306;
+ internal static string database = "supportbot";
+ internal static string username = "supportbot";
+ internal static string password = "";
- private static readonly Dictionary permissions = new Dictionary
- {
+ private static readonly Dictionary permissions = new Dictionary
+ {
// Public commands
- { "close", new ulong[]{ } },
- { "list", new ulong[]{ } },
- { "new", new ulong[]{ } },
- { "say", new ulong[]{ } },
- { "status", new ulong[]{ } },
- { "summary", new ulong[]{ } },
- { "transcript", new ulong[]{ } },
+ { "close", new ulong[]{ } },
+ { "list", new ulong[]{ } },
+ { "new", new ulong[]{ } },
+ { "say", new ulong[]{ } },
+ { "status", new ulong[]{ } },
+ { "summary", new ulong[]{ } },
+ { "transcript", new ulong[]{ } },
// Moderator commands
- { "add", new ulong[]{ } },
- { "addmessage", new ulong[]{ } },
- { "assign", new ulong[]{ } },
- { "blacklist", new ulong[]{ } },
- { "listassigned", new ulong[]{ } },
- { "listoldest", new ulong[]{ } },
- { "listunassigned", new ulong[]{ } },
- { "move", new ulong[]{ } },
- { "rassign", new ulong[]{ } },
- { "removemessage", new ulong[]{ } },
- { "setsummary", new ulong[]{ } },
- { "toggleactive", new ulong[]{ } },
- { "unassign", new ulong[]{ } },
- { "unblacklist", new ulong[]{ } },
+ { "add", new ulong[]{ } },
+ { "addmessage", new ulong[]{ } },
+ { "assign", new ulong[]{ } },
+ { "blacklist", new ulong[]{ } },
+ { "listassigned", new ulong[]{ } },
+ { "listoldest", new ulong[]{ } },
+ { "listunassigned", new ulong[]{ } },
+ { "move", new ulong[]{ } },
+ { "rassign", new ulong[]{ } },
+ { "removemessage", new ulong[]{ } },
+ { "setsummary", new ulong[]{ } },
+ { "toggleactive", new ulong[]{ } },
+ { "unassign", new ulong[]{ } },
+ { "unblacklist", new ulong[]{ } },
// Admin commands
- { "addstaff", new ulong[]{ } },
- { "reload", new ulong[]{ } },
- { "removestaff", new ulong[]{ } },
- { "setticket", new ulong[]{ } },
- { "unsetticket", new ulong[]{ } },
- };
+ { "addstaff", new ulong[]{ } },
+ { "reload", new ulong[]{ } },
+ { "removestaff", new ulong[]{ } },
+ { "setticket", new ulong[]{ } },
+ { "unsetticket", new ulong[]{ } },
+ };
+
+ public static void LoadConfig()
+ {
+ // Writes default config to file if it does not already exist
+ if (!File.Exists("./config.yml"))
+ {
+ File.WriteAllText("./config.yml", Encoding.UTF8.GetString(Resources.default_config));
+ }
- public static void LoadConfig()
- {
- // Writes default config to file if it does not already exist
- if (!File.Exists("./config.yml"))
- {
- File.WriteAllText("./config.yml", Encoding.UTF8.GetString(Resources.default_config));
- }
+ // Reads config contents into FileStream
+ FileStream stream = File.OpenRead("./config.yml");
- // Reads config contents into FileStream
- FileStream stream = File.OpenRead("./config.yml");
+ // Converts the FileStream into a YAML object
+ IDeserializer deserializer = new DeserializerBuilder().Build();
+ object yamlObject = deserializer.Deserialize(new StreamReader(stream));
- // Converts the FileStream into a YAML object
- IDeserializer deserializer = new DeserializerBuilder().Build();
- object yamlObject = deserializer.Deserialize(new StreamReader(stream));
+ // Converts the YAML object into a JSON object as the YAML ones do not support traversal or selection of nodes by name
+ ISerializer serializer = new SerializerBuilder().JsonCompatible().Build();
+ JObject json = JObject.Parse(serializer.Serialize(yamlObject));
- // Converts the YAML object into a JSON object as the YAML ones do not support traversal or selection of nodes by name
- ISerializer serializer = new SerializerBuilder().JsonCompatible().Build();
- JObject json = JObject.Parse(serializer.Serialize(yamlObject));
+ // Sets up the bot
+ token = json.SelectToken("bot.token").Value() ?? "";
+ prefix = json.SelectToken("bot.prefix").Value() ?? "";
+ logChannel = json.SelectToken("bot.log-channel").Value();
+ ticketCategory = json.SelectToken("bot.ticket-category")?.Value() ?? 0;
+ reactionMessage = json.SelectToken("bot.reaction-message")?.Value() ?? 0;
+ welcomeMessage = json.SelectToken("bot.welcome-message").Value() ?? "";
+ logLevel = json.SelectToken("bot.console-log-level").Value() ?? "";
+ timestampFormat = json.SelectToken("bot.timestamp-format").Value() ?? "yyyy-MM-dd HH:mm";
+ randomAssignment = json.SelectToken("bot.random-assignment")?.Value() ?? false;
+ randomAssignRoleOverride = json.SelectToken("bot.random-assign-role-override")?.Value() ?? false;
+ presenceType = json.SelectToken("bot.presence-type")?.Value() ?? "Playing";
+ presenceText = json.SelectToken("bot.presence-text")?.Value() ?? "";
- // Sets up the bot
- token = json.SelectToken("bot.token").Value() ?? "";
- prefix = json.SelectToken("bot.prefix").Value() ?? "";
- logChannel = json.SelectToken("bot.log-channel").Value();
- ticketCategory = json.SelectToken("bot.ticket-category")?.Value() ?? 0;
- reactionMessage = json.SelectToken("bot.reaction-message")?.Value() ?? 0;
- welcomeMessage = json.SelectToken("bot.welcome-message").Value() ?? "";
- logLevel = json.SelectToken("bot.console-log-level").Value() ?? "";
- timestampFormat = json.SelectToken("bot.timestamp-format").Value() ?? "yyyy-MM-dd HH:mm";
- randomAssignment = json.SelectToken("bot.random-assignment")?.Value() ?? false;
- randomAssignRoleOverride = json.SelectToken("bot.random-assign-role-override")?.Value() ?? false;
- presenceType = json.SelectToken("bot.presence-type")?.Value() ?? "Playing";
- presenceText = json.SelectToken("bot.presence-text")?.Value() ?? "";
+ ticketUpdatedNotifications = json.SelectToken("notifications.ticket-updated")?.Value() ?? false;
+ ticketUpdatedNotificationDelay = json.SelectToken("notifications.ticket-updated-delay")?.Value() ?? 0.0;
+ assignmentNotifications = json.SelectToken("notifications.assignment")?.Value() ?? false;
+ closingNotifications = json.SelectToken("notifications.closing")?.Value() ?? false;
- ticketUpdatedNotifications = json.SelectToken("notifications.ticket-updated")?.Value() ?? false;
- ticketUpdatedNotificationDelay = json.SelectToken("notifications.ticket-updated-delay")?.Value() ?? 0.0;
- assignmentNotifications = json.SelectToken("notifications.assignment")?.Value() ?? false;
- closingNotifications = json.SelectToken("notifications.closing")?.Value() ?? false;
+ // Reads database info
+ hostName = json.SelectToken("database.address")?.Value() ?? "";
+ port = json.SelectToken("database.port")?.Value() ?? 3306;
+ database = json.SelectToken("database.name")?.Value() ?? "supportchild";
+ username = json.SelectToken("database.user")?.Value() ?? "supportchild";
+ password = json.SelectToken("database.password")?.Value() ?? "";
- // Reads database info
- hostName = json.SelectToken("database.address")?.Value() ?? "";
- port = json.SelectToken("database.port")?.Value() ?? 3306;
- database = json.SelectToken("database.name")?.Value() ?? "supportbot";
- username = json.SelectToken("database.user")?.Value() ?? "supportbot";
- password = json.SelectToken("database.password")?.Value() ?? "";
+ timestampFormat = timestampFormat.Trim();
- timestampFormat = timestampFormat.Trim();
+ foreach (KeyValuePair node in permissions.ToList())
+ {
+ try
+ {
+ permissions[node.Key] = json.SelectToken("permissions." + node.Key).Value().Values().ToArray();
+ }
+ catch (ArgumentNullException)
+ {
+ Console.WriteLine("Permission node '" + node.Key + "' was not found in the config, using default value: []");
+ }
+ }
+ }
- foreach (KeyValuePair node in permissions.ToList())
- {
- try
- {
- permissions[node.Key] = json.SelectToken("permissions." + node.Key).Value().Values().ToArray();
- }
- catch (ArgumentNullException)
- {
- Console.WriteLine("Permission node '" + node.Key + "' was not found in the config, using default value: []");
- }
- }
- }
-
- ///
- /// Checks whether a user has a specific permission.
- ///
- /// The Discord user to check.
- /// The permission name to check.
- ///
- public static bool HasPermission(DiscordMember member, string permission)
- {
- return member.Roles.Any(role => permissions[permission].Contains(role.Id)) || permissions[permission].Contains(member.Guild.Id);
- }
- }
-}
+ ///
+ /// Checks whether a user has a specific permission.
+ ///
+ /// The Discord user to check.
+ /// The permission name to check.
+ ///
+ public static bool HasPermission(DiscordMember member, string permission)
+ {
+ return member.Roles.Any(role => permissions[permission].Contains(role.Id)) || permissions[permission].Contains(member.Guild.Id);
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Database.cs b/SupportChild/Database.cs
index 9f1010b..57ecbca 100644
--- a/SupportChild/Database.cs
+++ b/SupportChild/Database.cs
@@ -5,687 +5,687 @@ using MySql.Data.MySqlClient;
namespace SupportChild
{
- public static class Database
- {
- private static string connectionString = "";
+ public static class Database
+ {
+ private static string connectionString = "";
- private static Random random = new Random();
+ private static Random random = new Random();
- public static void SetConnectionString(string host, int port, string database, string username, string password)
- {
- connectionString = "server=" + host +
- ";database=" + database +
- ";port=" + port +
- ";userid=" + username +
- ";password=" + password;
- }
- public static MySqlConnection GetConnection()
- {
- return new MySqlConnection(connectionString);
- }
- public static long GetNumberOfTickets()
- {
- try
- {
- using (MySqlConnection c = GetConnection())
- {
- MySqlCommand countTickets = new MySqlCommand("SELECT COUNT(*) FROM tickets", c);
- c.Open();
- return (long)countTickets.ExecuteScalar();
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Error occured when attempting to count number of open tickets: " + e);
- }
+ public static void SetConnectionString(string host, int port, string database, string username, string password)
+ {
+ connectionString = "server=" + host +
+ ";database=" + database +
+ ";port=" + port +
+ ";userid=" + username +
+ ";password=" + password;
+ }
+ public static MySqlConnection GetConnection()
+ {
+ return new MySqlConnection(connectionString);
+ }
+ public static long GetNumberOfTickets()
+ {
+ try
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ MySqlCommand countTickets = new MySqlCommand("SELECT COUNT(*) FROM tickets", c);
+ c.Open();
+ return (long)countTickets.ExecuteScalar();
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error occured when attempting to count number of open tickets: " + e);
+ }
- return -1;
- }
- public static long GetNumberOfClosedTickets()
- {
- try
- {
- using (MySqlConnection c = GetConnection())
- {
- MySqlCommand countTickets = new MySqlCommand("SELECT COUNT(*) FROM ticket_history", c);
- c.Open();
- return (long)countTickets.ExecuteScalar();
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Error occured when attempting to count number of open tickets: " + e);
- }
+ return -1;
+ }
+ public static long GetNumberOfClosedTickets()
+ {
+ try
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ MySqlCommand countTickets = new MySqlCommand("SELECT COUNT(*) FROM ticket_history", c);
+ c.Open();
+ return (long)countTickets.ExecuteScalar();
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Error occured when attempting to count number of open tickets: " + e);
+ }
- return -1;
- }
- public static void SetupTables()
- {
- using (MySqlConnection c = GetConnection())
- {
- MySqlCommand createTickets = new MySqlCommand(
- "CREATE TABLE IF NOT EXISTS tickets(" +
- "id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT," +
- "created_time DATETIME NOT NULL," +
- "creator_id BIGINT UNSIGNED NOT NULL," +
- "assigned_staff_id BIGINT UNSIGNED NOT NULL DEFAULT 0," +
- "summary VARCHAR(5000) NOT NULL," +
- "channel_id BIGINT UNSIGNED NOT NULL UNIQUE," +
- "INDEX(created_time, assigned_staff_id, channel_id))",
- c);
- MySqlCommand createTicketHistory = new MySqlCommand(
- "CREATE TABLE IF NOT EXISTS ticket_history(" +
- "id INT UNSIGNED NOT NULL PRIMARY KEY," +
- "created_time DATETIME NOT NULL," +
- "closed_time DATETIME NOT NULL," +
- "creator_id BIGINT UNSIGNED NOT NULL," +
- "assigned_staff_id BIGINT UNSIGNED NOT NULL DEFAULT 0," +
- "summary VARCHAR(5000) NOT NULL," +
- "channel_id BIGINT UNSIGNED NOT NULL UNIQUE," +
- "INDEX(created_time, closed_time, channel_id))",
- c);
- MySqlCommand createBlacklisted = new MySqlCommand(
- "CREATE TABLE IF NOT EXISTS blacklisted_users(" +
- "user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY," +
- "time DATETIME NOT NULL," +
- "moderator_id BIGINT UNSIGNED NOT NULL," +
- "INDEX(user_id, time))",
- c);
- MySqlCommand createStaffList = new MySqlCommand(
- "CREATE TABLE IF NOT EXISTS staff(" +
- "user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY," +
- "name VARCHAR(256) NOT NULL," +
- "active BOOLEAN NOT NULL DEFAULT true)",
- c);
- MySqlCommand createMessages = new MySqlCommand(
- "CREATE TABLE IF NOT EXISTS messages(" +
- "identifier VARCHAR(256) NOT NULL PRIMARY KEY," +
- "user_id BIGINT UNSIGNED NOT NULL," +
- "message VARCHAR(5000) NOT NULL)",
- c);
- c.Open();
- createTickets.ExecuteNonQuery();
- createBlacklisted.ExecuteNonQuery();
- createTicketHistory.ExecuteNonQuery();
- createStaffList.ExecuteNonQuery();
- createMessages.ExecuteNonQuery();
- }
- }
- public static bool IsOpenTicket(ulong channelID)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE channel_id=@channel_id", c);
- selection.Parameters.AddWithValue("@channel_id", channelID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ return -1;
+ }
+ public static void SetupTables()
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ MySqlCommand createTickets = new MySqlCommand(
+ "CREATE TABLE IF NOT EXISTS tickets(" +
+ "id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT," +
+ "created_time DATETIME NOT NULL," +
+ "creator_id BIGINT UNSIGNED NOT NULL," +
+ "assigned_staff_id BIGINT UNSIGNED NOT NULL DEFAULT 0," +
+ "summary VARCHAR(5000) NOT NULL," +
+ "channel_id BIGINT UNSIGNED NOT NULL UNIQUE," +
+ "INDEX(created_time, assigned_staff_id, channel_id))",
+ c);
+ MySqlCommand createTicketHistory = new MySqlCommand(
+ "CREATE TABLE IF NOT EXISTS ticket_history(" +
+ "id INT UNSIGNED NOT NULL PRIMARY KEY," +
+ "created_time DATETIME NOT NULL," +
+ "closed_time DATETIME NOT NULL," +
+ "creator_id BIGINT UNSIGNED NOT NULL," +
+ "assigned_staff_id BIGINT UNSIGNED NOT NULL DEFAULT 0," +
+ "summary VARCHAR(5000) NOT NULL," +
+ "channel_id BIGINT UNSIGNED NOT NULL UNIQUE," +
+ "INDEX(created_time, closed_time, channel_id))",
+ c);
+ MySqlCommand createBlacklisted = new MySqlCommand(
+ "CREATE TABLE IF NOT EXISTS blacklisted_users(" +
+ "user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY," +
+ "time DATETIME NOT NULL," +
+ "moderator_id BIGINT UNSIGNED NOT NULL," +
+ "INDEX(user_id, time))",
+ c);
+ MySqlCommand createStaffList = new MySqlCommand(
+ "CREATE TABLE IF NOT EXISTS staff(" +
+ "user_id BIGINT UNSIGNED NOT NULL PRIMARY KEY," +
+ "name VARCHAR(256) NOT NULL," +
+ "active BOOLEAN NOT NULL DEFAULT true)",
+ c);
+ MySqlCommand createMessages = new MySqlCommand(
+ "CREATE TABLE IF NOT EXISTS messages(" +
+ "identifier VARCHAR(256) NOT NULL PRIMARY KEY," +
+ "user_id BIGINT UNSIGNED NOT NULL," +
+ "message VARCHAR(5000) NOT NULL)",
+ c);
+ c.Open();
+ createTickets.ExecuteNonQuery();
+ createBlacklisted.ExecuteNonQuery();
+ createTicketHistory.ExecuteNonQuery();
+ createStaffList.ExecuteNonQuery();
+ createMessages.ExecuteNonQuery();
+ }
+ }
+ public static bool IsOpenTicket(ulong channelID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE channel_id=@channel_id", c);
+ selection.Parameters.AddWithValue("@channel_id", channelID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if ticket exists in the database
- if (!results.Read())
- {
- return false;
- }
- results.Close();
- }
- return true;
- }
- public static bool TryGetOpenTicket(ulong channelID, out Ticket ticket)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE channel_id=@channel_id", c);
- selection.Parameters.AddWithValue("@channel_id", channelID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ // Check if ticket exists in the database
+ if (!results.Read())
+ {
+ return false;
+ }
+ results.Close();
+ }
+ return true;
+ }
+ public static bool TryGetOpenTicket(ulong channelID, out Ticket ticket)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE channel_id=@channel_id", c);
+ selection.Parameters.AddWithValue("@channel_id", channelID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if ticket exists in the database
- if (!results.Read())
- {
- ticket = null;
- return false;
- }
+ // Check if ticket exists in the database
+ if (!results.Read())
+ {
+ ticket = null;
+ return false;
+ }
- ticket = new Ticket(results);
- results.Close();
- return true;
- }
- }
- public static bool TryGetOpenTicketByID(uint id, out Ticket ticket)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE id=@id", c);
- selection.Parameters.AddWithValue("@id", id);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ ticket = new Ticket(results);
+ results.Close();
+ return true;
+ }
+ }
+ public static bool TryGetOpenTicketByID(uint id, out Ticket ticket)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE id=@id", c);
+ selection.Parameters.AddWithValue("@id", id);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if open ticket exists in the database
- if (results.Read())
- {
- ticket = new Ticket(results);
- return true;
- }
+ // Check if open ticket exists in the database
+ if (results.Read())
+ {
+ ticket = new Ticket(results);
+ return true;
+ }
- ticket = null;
- return false;
- }
- }
- public static bool TryGetClosedTicket(uint id, out Ticket ticket)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM ticket_history WHERE id=@id", c);
- selection.Parameters.AddWithValue("@id", id);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ ticket = null;
+ return false;
+ }
+ }
+ public static bool TryGetClosedTicket(uint id, out Ticket ticket)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM ticket_history WHERE id=@id", c);
+ selection.Parameters.AddWithValue("@id", id);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if closed ticket exists in the database
- if (results.Read())
- {
- ticket = new Ticket(results);
- return true;
- }
+ // Check if closed ticket exists in the database
+ if (results.Read())
+ {
+ ticket = new Ticket(results);
+ return true;
+ }
- ticket = null;
- return false;
- }
- }
- public static bool TryGetOpenTickets(ulong userID, out List tickets)
- {
- tickets = null;
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE creator_id=@creator_id", c);
- selection.Parameters.AddWithValue("@creator_id", userID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ ticket = null;
+ return false;
+ }
+ }
+ public static bool TryGetOpenTickets(ulong userID, out List tickets)
+ {
+ tickets = null;
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE creator_id=@creator_id", c);
+ selection.Parameters.AddWithValue("@creator_id", userID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- if (!results.Read())
- {
- return false;
- }
+ if (!results.Read())
+ {
+ return false;
+ }
- tickets = new List { new Ticket(results) };
- while (results.Read())
- {
- tickets.Add(new Ticket(results));
- }
- results.Close();
- return true;
- }
- }
- public static bool TryGetOldestTickets(ulong userID, out List tickets, int listLimit)
- {
- tickets = null;
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets ORDER BY created_time ASC LIMIT @limit", c);
- selection.Parameters.AddWithValue("@creator_id", userID);
- selection.Parameters.AddWithValue("@limit", listLimit);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ tickets = new List { new Ticket(results) };
+ while (results.Read())
+ {
+ tickets.Add(new Ticket(results));
+ }
+ results.Close();
+ return true;
+ }
+ }
+ public static bool TryGetOldestTickets(ulong userID, out List tickets, int listLimit)
+ {
+ tickets = null;
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets ORDER BY created_time ASC LIMIT @limit", c);
+ selection.Parameters.AddWithValue("@creator_id", userID);
+ selection.Parameters.AddWithValue("@limit", listLimit);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- if (!results.Read())
- {
- return false;
- }
+ if (!results.Read())
+ {
+ return false;
+ }
- tickets = new List { new Ticket(results) };
- while (results.Read())
- {
- tickets.Add(new Ticket(results));
- }
- results.Close();
- return true;
- }
- }
- public static bool TryGetClosedTickets(ulong userID, out List tickets)
- {
- tickets = null;
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM ticket_history WHERE creator_id=@creator_id", c);
- selection.Parameters.AddWithValue("@creator_id", userID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ tickets = new List { new Ticket(results) };
+ while (results.Read())
+ {
+ tickets.Add(new Ticket(results));
+ }
+ results.Close();
+ return true;
+ }
+ }
+ public static bool TryGetClosedTickets(ulong userID, out List tickets)
+ {
+ tickets = null;
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM ticket_history WHERE creator_id=@creator_id", c);
+ selection.Parameters.AddWithValue("@creator_id", userID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- if (!results.Read())
- {
- return false;
- }
+ if (!results.Read())
+ {
+ return false;
+ }
- tickets = new List { new Ticket(results) };
- while (results.Read())
- {
- tickets.Add(new Ticket(results));
- }
- results.Close();
- return true;
- }
- }
- public static bool TryGetAssignedTickets(ulong staffID, out List tickets)
- {
- tickets = null;
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE assigned_staff_id=@assigned_staff_id", c);
- selection.Parameters.AddWithValue("@assigned_staff_id", staffID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ tickets = new List { new Ticket(results) };
+ while (results.Read())
+ {
+ tickets.Add(new Ticket(results));
+ }
+ results.Close();
+ return true;
+ }
+ }
+ public static bool TryGetAssignedTickets(ulong staffID, out List tickets)
+ {
+ tickets = null;
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM tickets WHERE assigned_staff_id=@assigned_staff_id", c);
+ selection.Parameters.AddWithValue("@assigned_staff_id", staffID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- if (!results.Read())
- {
- return false;
- }
+ if (!results.Read())
+ {
+ return false;
+ }
- tickets = new List { new Ticket(results) };
- while (results.Read())
- {
- tickets.Add(new Ticket(results));
- }
- results.Close();
- return true;
- }
- }
- public static long NewTicket(ulong memberID, ulong staffID, ulong ticketID)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand cmd = new MySqlCommand(
- @"INSERT INTO tickets (created_time, creator_id, assigned_staff_id, summary, channel_id) VALUES (UTC_TIMESTAMP(), @creator_id, @assigned_staff_id, @summary, @channel_id);",
- c);
- cmd.Parameters.AddWithValue("@creator_id", memberID);
- cmd.Parameters.AddWithValue("@assigned_staff_id", staffID);
- cmd.Parameters.AddWithValue("@summary", "");
- cmd.Parameters.AddWithValue("@channel_id", ticketID);
- cmd.ExecuteNonQuery();
- return cmd.LastInsertedId;
- }
- }
+ tickets = new List { new Ticket(results) };
+ while (results.Read())
+ {
+ tickets.Add(new Ticket(results));
+ }
+ results.Close();
+ return true;
+ }
+ }
+ public static long NewTicket(ulong memberID, ulong staffID, ulong ticketID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand cmd = new MySqlCommand(
+ @"INSERT INTO tickets (created_time, creator_id, assigned_staff_id, summary, channel_id) VALUES (UTC_TIMESTAMP(), @creator_id, @assigned_staff_id, @summary, @channel_id);",
+ c);
+ cmd.Parameters.AddWithValue("@creator_id", memberID);
+ cmd.Parameters.AddWithValue("@assigned_staff_id", staffID);
+ cmd.Parameters.AddWithValue("@summary", "");
+ cmd.Parameters.AddWithValue("@channel_id", ticketID);
+ cmd.ExecuteNonQuery();
+ return cmd.LastInsertedId;
+ }
+ }
- public static void ArchiveTicket(Ticket ticket)
- {
- // Check if ticket already exists in the archive
- if (TryGetClosedTicket(ticket.id, out Ticket _))
- {
- using (MySqlConnection c = GetConnection())
- {
- MySqlCommand deleteTicket = new MySqlCommand(@"DELETE FROM ticket_history WHERE id=@id OR channel_id=@channel_id", c);
- deleteTicket.Parameters.AddWithValue("@id", ticket.id);
- deleteTicket.Parameters.AddWithValue("@channel_id", ticket.channelID);
+ public static void ArchiveTicket(Ticket ticket)
+ {
+ // Check if ticket already exists in the archive
+ if (TryGetClosedTicket(ticket.id, out Ticket _))
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ MySqlCommand deleteTicket = new MySqlCommand(@"DELETE FROM ticket_history WHERE id=@id OR channel_id=@channel_id", c);
+ deleteTicket.Parameters.AddWithValue("@id", ticket.id);
+ deleteTicket.Parameters.AddWithValue("@channel_id", ticket.channelID);
- c.Open();
- deleteTicket.Prepare();
- deleteTicket.ExecuteNonQuery();
- }
- }
+ c.Open();
+ deleteTicket.Prepare();
+ deleteTicket.ExecuteNonQuery();
+ }
+ }
- using (MySqlConnection c = GetConnection())
- {
- // Create an entry in the ticket history database
- MySqlCommand archiveTicket = new MySqlCommand(@"INSERT INTO ticket_history (id, created_time, closed_time, creator_id, assigned_staff_id, summary, channel_id) VALUES (@id, @created_time, UTC_TIMESTAMP(), @creator_id, @assigned_staff_id, @summary, @channel_id);", c);
- archiveTicket.Parameters.AddWithValue("@id", ticket.id);
- archiveTicket.Parameters.AddWithValue("@created_time", ticket.createdTime);
- archiveTicket.Parameters.AddWithValue("@creator_id", ticket.creatorID);
- archiveTicket.Parameters.AddWithValue("@assigned_staff_id", ticket.assignedStaffID);
- archiveTicket.Parameters.AddWithValue("@summary", ticket.summary);
- archiveTicket.Parameters.AddWithValue("@channel_id", ticket.channelID);
+ using (MySqlConnection c = GetConnection())
+ {
+ // Create an entry in the ticket history database
+ MySqlCommand archiveTicket = new MySqlCommand(@"INSERT INTO ticket_history (id, created_time, closed_time, creator_id, assigned_staff_id, summary, channel_id) VALUES (@id, @created_time, UTC_TIMESTAMP(), @creator_id, @assigned_staff_id, @summary, @channel_id);", c);
+ archiveTicket.Parameters.AddWithValue("@id", ticket.id);
+ archiveTicket.Parameters.AddWithValue("@created_time", ticket.createdTime);
+ archiveTicket.Parameters.AddWithValue("@creator_id", ticket.creatorID);
+ archiveTicket.Parameters.AddWithValue("@assigned_staff_id", ticket.assignedStaffID);
+ archiveTicket.Parameters.AddWithValue("@summary", ticket.summary);
+ archiveTicket.Parameters.AddWithValue("@channel_id", ticket.channelID);
- c.Open();
- archiveTicket.Prepare();
- archiveTicket.ExecuteNonQuery();
- }
- }
+ c.Open();
+ archiveTicket.Prepare();
+ archiveTicket.ExecuteNonQuery();
+ }
+ }
- public static void DeleteOpenTicket(uint ticketID)
- {
- using (MySqlConnection c = GetConnection())
- {
- MySqlCommand deletion = new MySqlCommand(@"DELETE FROM tickets WHERE id=@id", c);
- deletion.Parameters.AddWithValue("@id", ticketID);
+ public static void DeleteOpenTicket(uint ticketID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ MySqlCommand deletion = new MySqlCommand(@"DELETE FROM tickets WHERE id=@id", c);
+ deletion.Parameters.AddWithValue("@id", ticketID);
- c.Open();
- deletion.Prepare();
- deletion.ExecuteNonQuery();
- }
- }
+ c.Open();
+ deletion.Prepare();
+ deletion.ExecuteNonQuery();
+ }
+ }
- public static bool IsBlacklisted(ulong userID)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM blacklisted_users WHERE user_id=@user_id", c);
- selection.Parameters.AddWithValue("@user_id", userID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ public static bool IsBlacklisted(ulong userID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM blacklisted_users WHERE user_id=@user_id", c);
+ selection.Parameters.AddWithValue("@user_id", userID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if user is blacklisted
- if (results.Read())
- {
- return true;
- }
- results.Close();
- }
+ // Check if user is blacklisted
+ if (results.Read())
+ {
+ return true;
+ }
+ results.Close();
+ }
- return false;
- }
- public static bool Blacklist(ulong blacklistedID, ulong staffID)
- {
- using (MySqlConnection c = GetConnection())
- {
- try
- {
- c.Open();
- MySqlCommand cmd = new MySqlCommand(@"INSERT INTO blacklisted_users (user_id,time,moderator_id) VALUES (@user_id, UTC_TIMESTAMP(), @moderator_id);", c);
- cmd.Parameters.AddWithValue("@user_id", blacklistedID);
- cmd.Parameters.AddWithValue("@moderator_id", staffID);
- cmd.Prepare();
- return cmd.ExecuteNonQuery() > 0;
- }
- catch (MySqlException)
- {
- return false;
- }
- }
- }
- public static bool Unblacklist(ulong blacklistedID)
- {
- using (MySqlConnection c = GetConnection())
- {
- try
- {
- c.Open();
- MySqlCommand cmd = new MySqlCommand(@"DELETE FROM blacklisted_users WHERE user_id=@user_id", c);
- cmd.Parameters.AddWithValue("@user_id", blacklistedID);
- cmd.Prepare();
- return cmd.ExecuteNonQuery() > 0;
- }
- catch (MySqlException)
- {
- return false;
- }
+ return false;
+ }
+ public static bool Blacklist(ulong blacklistedID, ulong staffID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ try
+ {
+ c.Open();
+ MySqlCommand cmd = new MySqlCommand(@"INSERT INTO blacklisted_users (user_id,time,moderator_id) VALUES (@user_id, UTC_TIMESTAMP(), @moderator_id);", c);
+ cmd.Parameters.AddWithValue("@user_id", blacklistedID);
+ cmd.Parameters.AddWithValue("@moderator_id", staffID);
+ cmd.Prepare();
+ return cmd.ExecuteNonQuery() > 0;
+ }
+ catch (MySqlException)
+ {
+ return false;
+ }
+ }
+ }
+ public static bool Unblacklist(ulong blacklistedID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ try
+ {
+ c.Open();
+ MySqlCommand cmd = new MySqlCommand(@"DELETE FROM blacklisted_users WHERE user_id=@user_id", c);
+ cmd.Parameters.AddWithValue("@user_id", blacklistedID);
+ cmd.Prepare();
+ return cmd.ExecuteNonQuery() > 0;
+ }
+ catch (MySqlException)
+ {
+ return false;
+ }
- }
- }
- public static bool AssignStaff(Ticket ticket, ulong staffID)
- {
- using (MySqlConnection c = GetConnection())
- {
- try
- {
- c.Open();
- MySqlCommand update = new MySqlCommand(@"UPDATE tickets SET assigned_staff_id = @assigned_staff_id WHERE id = @id", c);
- update.Parameters.AddWithValue("@assigned_staff_id", staffID);
- update.Parameters.AddWithValue("@id", ticket.id);
- update.Prepare();
- return update.ExecuteNonQuery() > 0;
- }
- catch (MySqlException)
- {
- return false;
- }
+ }
+ }
+ public static bool AssignStaff(Ticket ticket, ulong staffID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ try
+ {
+ c.Open();
+ MySqlCommand update = new MySqlCommand(@"UPDATE tickets SET assigned_staff_id = @assigned_staff_id WHERE id = @id", c);
+ update.Parameters.AddWithValue("@assigned_staff_id", staffID);
+ update.Parameters.AddWithValue("@id", ticket.id);
+ update.Prepare();
+ return update.ExecuteNonQuery() > 0;
+ }
+ catch (MySqlException)
+ {
+ return false;
+ }
- }
- }
- public static bool UnassignStaff(Ticket ticket)
- {
- return AssignStaff(ticket, 0);
- }
- public static StaffMember GetRandomActiveStaff(ulong currentStaffID)
- {
- List staffMembers = GetActiveStaff(currentStaffID);
- if (!staffMembers.Any())
- {
- return null;
- }
+ }
+ }
+ public static bool UnassignStaff(Ticket ticket)
+ {
+ return AssignStaff(ticket, 0);
+ }
+ public static StaffMember GetRandomActiveStaff(ulong currentStaffID)
+ {
+ List staffMembers = GetActiveStaff(currentStaffID);
+ if (!staffMembers.Any())
+ {
+ return null;
+ }
- return staffMembers[random.Next(staffMembers.Count)];
- }
+ return staffMembers[random.Next(staffMembers.Count)];
+ }
- public static List GetActiveStaff(ulong currentStaffID = 0)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE active = true AND user_id != @user_id", c);
- selection.Parameters.AddWithValue("@user_id", currentStaffID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ public static List GetActiveStaff(ulong currentStaffID = 0)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE active = true AND user_id != @user_id", c);
+ selection.Parameters.AddWithValue("@user_id", currentStaffID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if staff exists in the database
- if (!results.Read())
- {
- return new List();
- }
+ // Check if staff exists in the database
+ if (!results.Read())
+ {
+ return new List();
+ }
- List staffMembers = new List { new StaffMember(results) };
- while (results.Read())
- {
- staffMembers.Add(new StaffMember(results));
- }
- results.Close();
+ List staffMembers = new List { new StaffMember(results) };
+ while (results.Read())
+ {
+ staffMembers.Add(new StaffMember(results));
+ }
+ results.Close();
- return staffMembers;
- }
- }
+ return staffMembers;
+ }
+ }
- public static List GetAllStaff(ulong currentStaffID = 0)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE user_id != @user_id", c);
- selection.Parameters.AddWithValue("@user_id", currentStaffID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ public static List GetAllStaff(ulong currentStaffID = 0)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE user_id != @user_id", c);
+ selection.Parameters.AddWithValue("@user_id", currentStaffID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if staff exist in the database
- if (!results.Read())
- {
- return new List();
- }
+ // Check if staff exist in the database
+ if (!results.Read())
+ {
+ return new List();
+ }
- List staffMembers = new List { new StaffMember(results) };
- while (results.Read())
- {
- staffMembers.Add(new StaffMember(results));
- }
- results.Close();
+ List staffMembers = new List { new StaffMember(results) };
+ while (results.Read())
+ {
+ staffMembers.Add(new StaffMember(results));
+ }
+ results.Close();
- return staffMembers;
- }
- }
+ return staffMembers;
+ }
+ }
- public static bool IsStaff(ulong staffID)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE user_id=@user_id", c);
- selection.Parameters.AddWithValue("@user_id", staffID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ public static bool IsStaff(ulong staffID)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE user_id=@user_id", c);
+ selection.Parameters.AddWithValue("@user_id", staffID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if ticket exists in the database
- if (!results.Read())
- {
- return false;
- }
- results.Close();
- return true;
- }
- }
- public static bool TryGetStaff(ulong staffID, out StaffMember staffMember)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE user_id=@user_id", c);
- selection.Parameters.AddWithValue("@user_id", staffID);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ // Check if ticket exists in the database
+ if (!results.Read())
+ {
+ return false;
+ }
+ results.Close();
+ return true;
+ }
+ }
+ public static bool TryGetStaff(ulong staffID, out StaffMember staffMember)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM staff WHERE user_id=@user_id", c);
+ selection.Parameters.AddWithValue("@user_id", staffID);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if ticket exists in the database
- if (!results.Read())
- {
- staffMember = null;
- return false;
- }
- staffMember = new StaffMember(results);
- results.Close();
- return true;
- }
- }
+ // Check if ticket exists in the database
+ if (!results.Read())
+ {
+ staffMember = null;
+ return false;
+ }
+ staffMember = new StaffMember(results);
+ results.Close();
+ return true;
+ }
+ }
- public static List GetAllMessages()
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM messages", c);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ public static List GetAllMessages()
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM messages", c);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if messages exist in the database
- if (!results.Read())
- {
- return new List();
- }
+ // Check if messages exist in the database
+ if (!results.Read())
+ {
+ return new List();
+ }
- List messages = new List { new Message(results) };
- while (results.Read())
- {
- messages.Add(new Message(results));
- }
- results.Close();
+ List messages = new List { new Message(results) };
+ while (results.Read())
+ {
+ messages.Add(new Message(results));
+ }
+ results.Close();
- return messages;
- }
- }
+ return messages;
+ }
+ }
- public static bool TryGetMessage(string identifier, out Message message)
- {
- using (MySqlConnection c = GetConnection())
- {
- c.Open();
- MySqlCommand selection = new MySqlCommand(@"SELECT * FROM messages WHERE identifier=@identifier", c);
- selection.Parameters.AddWithValue("@identifier", identifier);
- selection.Prepare();
- MySqlDataReader results = selection.ExecuteReader();
+ public static bool TryGetMessage(string identifier, out Message message)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ c.Open();
+ MySqlCommand selection = new MySqlCommand(@"SELECT * FROM messages WHERE identifier=@identifier", c);
+ selection.Parameters.AddWithValue("@identifier", identifier);
+ selection.Prepare();
+ MySqlDataReader results = selection.ExecuteReader();
- // Check if ticket exists in the database
- if (!results.Read())
- {
- message = null;
- return false;
- }
- message = new Message(results);
- results.Close();
- return true;
- }
- }
+ // Check if ticket exists in the database
+ if (!results.Read())
+ {
+ message = null;
+ return false;
+ }
+ message = new Message(results);
+ results.Close();
+ return true;
+ }
+ }
- public static bool AddMessage(string identifier, ulong userID, string message)
- {
- using (MySqlConnection c = GetConnection())
- {
- try
- {
- c.Open();
- MySqlCommand cmd = new MySqlCommand(@"INSERT INTO messages (identifier,user_id,message) VALUES (@identifier, @user_id, @message);", c);
- cmd.Parameters.AddWithValue("@identifier", identifier);
- cmd.Parameters.AddWithValue("@user_id", userID);
- cmd.Parameters.AddWithValue("@message", message);
- cmd.Prepare();
- return cmd.ExecuteNonQuery() > 0;
- }
- catch (MySqlException)
- {
- return false;
- }
- }
- }
+ public static bool AddMessage(string identifier, ulong userID, string message)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ try
+ {
+ c.Open();
+ MySqlCommand cmd = new MySqlCommand(@"INSERT INTO messages (identifier,user_id,message) VALUES (@identifier, @user_id, @message);", c);
+ cmd.Parameters.AddWithValue("@identifier", identifier);
+ cmd.Parameters.AddWithValue("@user_id", userID);
+ cmd.Parameters.AddWithValue("@message", message);
+ cmd.Prepare();
+ return cmd.ExecuteNonQuery() > 0;
+ }
+ catch (MySqlException)
+ {
+ return false;
+ }
+ }
+ }
- public static bool RemoveMessage(string identifier)
- {
- using (MySqlConnection c = GetConnection())
- {
- try
- {
- c.Open();
- MySqlCommand cmd = new MySqlCommand(@"DELETE FROM messages WHERE identifier=@identifier", c);
- cmd.Parameters.AddWithValue("@identifier", identifier);
- cmd.Prepare();
- return cmd.ExecuteNonQuery() > 0;
- }
- catch (MySqlException)
- {
- return false;
- }
+ public static bool RemoveMessage(string identifier)
+ {
+ using (MySqlConnection c = GetConnection())
+ {
+ try
+ {
+ c.Open();
+ MySqlCommand cmd = new MySqlCommand(@"DELETE FROM messages WHERE identifier=@identifier", c);
+ cmd.Parameters.AddWithValue("@identifier", identifier);
+ cmd.Prepare();
+ return cmd.ExecuteNonQuery() > 0;
+ }
+ catch (MySqlException)
+ {
+ return false;
+ }
- }
- }
+ }
+ }
- public class Ticket
- {
- public uint id;
- public DateTime createdTime;
- public ulong creatorID;
- public ulong assignedStaffID;
- public string summary;
- public ulong channelID;
+ public class Ticket
+ {
+ public uint id;
+ public DateTime createdTime;
+ public ulong creatorID;
+ public ulong assignedStaffID;
+ public string summary;
+ public ulong channelID;
- public Ticket(MySqlDataReader reader)
- {
- id = reader.GetUInt32("id");
- createdTime = reader.GetDateTime("created_time");
- creatorID = reader.GetUInt64("creator_id");
- assignedStaffID = reader.GetUInt64("assigned_staff_id");
- summary = reader.GetString("summary");
- channelID = reader.GetUInt64("channel_id");
- }
+ public Ticket(MySqlDataReader reader)
+ {
+ this.id = reader.GetUInt32("id");
+ this.createdTime = reader.GetDateTime("created_time");
+ this.creatorID = reader.GetUInt64("creator_id");
+ this.assignedStaffID = reader.GetUInt64("assigned_staff_id");
+ this.summary = reader.GetString("summary");
+ this.channelID = reader.GetUInt64("channel_id");
+ }
- public string FormattedCreatedTime()
- {
- return createdTime.ToString(Config.timestampFormat);
- }
- }
- public class StaffMember
- {
- public ulong userID;
- public string name;
- public bool active;
+ public string FormattedCreatedTime()
+ {
+ return this.createdTime.ToString(Config.timestampFormat);
+ }
+ }
+ public class StaffMember
+ {
+ public ulong userID;
+ public string name;
+ public bool active;
- public StaffMember(MySqlDataReader reader)
- {
- userID = reader.GetUInt64("user_id");
- name = reader.GetString("name");
- active = reader.GetBoolean("active");
- }
- }
+ public StaffMember(MySqlDataReader reader)
+ {
+ this.userID = reader.GetUInt64("user_id");
+ this.name = reader.GetString("name");
+ this.active = reader.GetBoolean("active");
+ }
+ }
- public class Message
- {
- public string identifier;
- public ulong userID;
- public string message;
+ public class Message
+ {
+ public string identifier;
+ public ulong userID;
+ public string message;
- public Message(MySqlDataReader reader)
- {
- identifier = reader.GetString("identifier");
- userID = reader.GetUInt64("user_id");
- message = reader.GetString("message");
- }
- }
- }
-}
+ public Message(MySqlDataReader reader)
+ {
+ this.identifier = reader.GetString("identifier");
+ this.userID = reader.GetUInt64("user_id");
+ this.message = reader.GetString("message");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/EventHandler.cs b/SupportChild/EventHandler.cs
index 295d32e..e5f61f8 100644
--- a/SupportChild/EventHandler.cs
+++ b/SupportChild/EventHandler.cs
@@ -12,296 +12,296 @@ using Microsoft.Extensions.Logging;
namespace SupportChild
{
- internal class EventHandler
- {
- private DiscordClient discordClient;
+ internal class EventHandler
+ {
+ private DiscordClient discordClient;
- //DateTime for the end of the cooldown
- private static Dictionary reactionTicketCooldowns = new Dictionary();
+ //DateTime for the end of the cooldown
+ private static Dictionary reactionTicketCooldowns = new Dictionary();
- public EventHandler(DiscordClient client)
- {
- discordClient = client;
- }
+ public EventHandler(DiscordClient client)
+ {
+ this.discordClient = client;
+ }
- internal Task OnReady(DiscordClient client, ReadyEventArgs e)
- {
- discordClient.Logger.Log(LogLevel.Information, "Client is ready to process events.");
+ internal Task OnReady(DiscordClient client, ReadyEventArgs e)
+ {
+ discordClient.Logger.Log(LogLevel.Information, "Client is ready to process events.");
- // Checking activity type
- if (!Enum.TryParse(Config.presenceType, true, out ActivityType activityType))
- {
- Console.WriteLine("Presence type '" + Config.presenceType + "' invalid, using 'Playing' instead.");
- activityType = ActivityType.Playing;
- }
+ // Checking activity type
+ if (!Enum.TryParse(Config.presenceType, true, out ActivityType activityType))
+ {
+ Console.WriteLine("Presence type '" + Config.presenceType + "' invalid, using 'Playing' instead.");
+ activityType = ActivityType.Playing;
+ }
- discordClient.UpdateStatusAsync(new DiscordActivity(Config.presenceText, activityType), UserStatus.Online);
- return Task.CompletedTask;
- }
+ this.discordClient.UpdateStatusAsync(new DiscordActivity(Config.presenceText, activityType), UserStatus.Online);
+ return Task.CompletedTask;
+ }
- internal Task OnGuildAvailable(DiscordClient client, GuildCreateEventArgs e)
- {
- discordClient.Logger.Log(LogLevel.Information, $"Guild available: {e.Guild.Name}");
+ internal Task OnGuildAvailable(DiscordClient client, GuildCreateEventArgs e)
+ {
+ discordClient.Logger.Log(LogLevel.Information, $"Guild available: {e.Guild.Name}");
- IReadOnlyDictionary roles = e.Guild.Roles;
+ IReadOnlyDictionary roles = e.Guild.Roles;
- foreach ((ulong roleID, DiscordRole role) in roles)
- {
- discordClient.Logger.Log(LogLevel.Information, role.Name.PadRight(40, '.') + roleID);
- }
- return Task.CompletedTask;
- }
+ foreach ((ulong roleID, DiscordRole role) in roles)
+ {
+ discordClient.Logger.Log(LogLevel.Information, role.Name.PadRight(40, '.') + roleID);
+ }
+ return Task.CompletedTask;
+ }
- internal Task OnClientError(DiscordClient client, ClientErrorEventArgs e)
- {
- discordClient.Logger.Log(LogLevel.Error, $"Exception occured: {e.Exception.GetType()}: {e.Exception}");
+ internal Task OnClientError(DiscordClient client, ClientErrorEventArgs e)
+ {
+ discordClient.Logger.Log(LogLevel.Error, $"Exception occured: {e.Exception.GetType()}: {e.Exception}");
- return Task.CompletedTask;
- }
+ return Task.CompletedTask;
+ }
- internal async Task OnMessageCreated(DiscordClient client, MessageCreateEventArgs e)
- {
- if (e.Author.IsBot)
- {
- return;
- }
+ internal async Task OnMessageCreated(DiscordClient client, MessageCreateEventArgs e)
+ {
+ if (e.Author.IsBot)
+ {
+ return;
+ }
- // Check if ticket exists in the database and ticket notifications are enabled
- if (!Database.TryGetOpenTicket(e.Channel.Id, out Database.Ticket ticket) || !Config.ticketUpdatedNotifications)
- {
- return;
- }
+ // Check if ticket exists in the database and ticket notifications are enabled
+ if (!Database.TryGetOpenTicket(e.Channel.Id, out Database.Ticket ticket) || !Config.ticketUpdatedNotifications)
+ {
+ 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
- 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))
- {
- try
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "A ticket you are assigned to has been updated: " + e.Channel.Mention
- };
+ // 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
+ 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))
+ {
+ try
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "A ticket you are assigned to has been updated: " + e.Channel.Mention
+ };
- DiscordMember staffMember = await e.Guild.GetMemberAsync(ticket.assignedStaffID);
- await staffMember.SendMessageAsync(message);
- }
- catch (NotFoundException) { }
- catch (UnauthorizedException) { }
- }
- }
+ DiscordMember staffMember = await e.Guild.GetMemberAsync(ticket.assignedStaffID);
+ await staffMember.SendMessageAsync(message);
+ }
+ catch (NotFoundException) { }
+ catch (UnauthorizedException) { }
+ }
+ }
- internal Task OnCommandError(CommandsNextExtension commandSystem, CommandErrorEventArgs e)
- {
- switch (e.Exception)
- {
- case CommandNotFoundException _:
- return Task.CompletedTask;
- case ChecksFailedException _:
- {
- foreach (CheckBaseAttribute attr in ((ChecksFailedException)e.Exception).FailedChecks)
- {
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = ParseFailedCheck(attr)
- };
- e.Context?.Channel?.SendMessageAsync(error);
- }
- return Task.CompletedTask;
- }
+ internal Task OnCommandError(CommandsNextExtension commandSystem, CommandErrorEventArgs e)
+ {
+ switch (e.Exception)
+ {
+ case CommandNotFoundException _:
+ return Task.CompletedTask;
+ case ChecksFailedException _:
+ {
+ foreach (CheckBaseAttribute attr in ((ChecksFailedException)e.Exception).FailedChecks)
+ {
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = this.ParseFailedCheck(attr)
+ };
+ e.Context?.Channel?.SendMessageAsync(error);
+ }
+ return Task.CompletedTask;
+ }
- default:
- {
- discordClient.Logger.Log(LogLevel.Error, $"Exception occured: {e.Exception.GetType()}: {e.Exception}");
- DiscordEmbed error = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Red,
- Description = "Internal error occured, please report this to the developer."
- };
- e.Context?.Channel?.SendMessageAsync(error);
- return Task.CompletedTask;
- }
- }
- }
+ default:
+ {
+ discordClient.Logger.Log(LogLevel.Error, $"Exception occured: {e.Exception.GetType()}: {e.Exception}");
+ DiscordEmbed error = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Red,
+ Description = "Internal error occured, please report this to the developer."
+ };
+ e.Context?.Channel?.SendMessageAsync(error);
+ return Task.CompletedTask;
+ }
+ }
+ }
- internal async Task OnReactionAdded(DiscordClient client, MessageReactionAddEventArgs e)
- {
- if (e.Message.Id != Config.reactionMessage) return;
+ internal async Task OnReactionAdded(DiscordClient client, MessageReactionAddEventArgs e)
+ {
+ if (e.Message.Id != Config.reactionMessage) return;
- DiscordGuild guild = e.Message.Channel.Guild;
- DiscordMember member = await guild.GetMemberAsync(e.User.Id);
+ DiscordGuild guild = e.Message.Channel.Guild;
+ DiscordMember member = await guild.GetMemberAsync(e.User.Id);
- if (!Config.HasPermission(member, "new") || Database.IsBlacklisted(member.Id)) return;
- if (reactionTicketCooldowns.ContainsKey(member.Id))
- {
- if (reactionTicketCooldowns[member.Id] > DateTime.Now) return; // cooldown has not expired
- else reactionTicketCooldowns.Remove(member.Id); // cooldown exists but has expired, delete it
- }
+ if (!Config.HasPermission(member, "new") || Database.IsBlacklisted(member.Id)) return;
+ if (reactionTicketCooldowns.ContainsKey(member.Id))
+ {
+ if (reactionTicketCooldowns[member.Id] > DateTime.Now) return; // cooldown has not expired
+ else reactionTicketCooldowns.Remove(member.Id); // cooldown exists but has expired, delete it
+ }
- DiscordChannel category = guild.GetChannel(Config.ticketCategory);
- DiscordChannel ticketChannel = await guild.CreateChannelAsync("ticket", ChannelType.Text, category);
+ DiscordChannel category = guild.GetChannel(Config.ticketCategory);
+ DiscordChannel ticketChannel = await guild.CreateChannelAsync("ticket", ChannelType.Text, category);
- if (ticketChannel == null) return;
+ if (ticketChannel == null) return;
- ulong staffID = 0;
- if (Config.randomAssignment)
- {
- staffID = Database.GetRandomActiveStaff(0)?.userID ?? 0;
- }
+ ulong staffID = 0;
+ if (Config.randomAssignment)
+ {
+ staffID = Database.GetRandomActiveStaff(0)?.userID ?? 0;
+ }
- long id = Database.NewTicket(member.Id, staffID, ticketChannel.Id);
- reactionTicketCooldowns.Add(member.Id, DateTime.Now.AddSeconds(10)); // add a cooldown which expires in 10 seconds
- string ticketID = id.ToString("00000");
+ long id = Database.NewTicket(member.Id, staffID, ticketChannel.Id);
+ reactionTicketCooldowns.Add(member.Id, DateTime.Now.AddSeconds(10)); // add a cooldown which expires in 10 seconds
+ string ticketID = id.ToString("00000");
- await ticketChannel.ModifyAsync(model => model.Name = "ticket-" + ticketID);
- await ticketChannel.AddOverwriteAsync(member, Permissions.AccessChannels, Permissions.None);
- await ticketChannel.SendMessageAsync("Hello, " + member.Mention + "!\n" + Config.welcomeMessage);
+ await ticketChannel.ModifyAsync(model => model.Name = "ticket-" + ticketID);
+ await ticketChannel.AddOverwriteAsync(member, Permissions.AccessChannels, Permissions.None);
+ await ticketChannel.SendMessageAsync("Hello, " + member.Mention + "!\n" + Config.welcomeMessage);
- // Remove user's reaction
- await e.Message.DeleteReactionAsync(e.Emoji, e.User);
+ // Remove user's reaction
+ await e.Message.DeleteReactionAsync(e.Emoji, e.User);
- // Refreshes the channel as changes were made to it above
- ticketChannel = await SupportChild.GetClient().GetChannelAsync(ticketChannel.Id);
+ // Refreshes the channel as changes were made to it above
+ ticketChannel = await SupportChild.GetClient().GetChannelAsync(ticketChannel.Id);
- if (staffID != 0)
- {
- DiscordEmbed assignmentMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket was randomly assigned to <@" + staffID + ">."
- };
- await ticketChannel.SendMessageAsync(assignmentMessage);
+ if (staffID != 0)
+ {
+ DiscordEmbed assignmentMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket was randomly assigned to <@" + staffID + ">."
+ };
+ await ticketChannel.SendMessageAsync(assignmentMessage);
- if (Config.assignmentNotifications)
- {
- DiscordEmbed message = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "You have been randomly assigned to a newly opened support ticket: " +
- ticketChannel.Mention
- };
+ if (Config.assignmentNotifications)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "You have been randomly assigned to a newly opened support ticket: " +
+ ticketChannel.Mention
+ };
- try
- {
- DiscordMember staffMember = await guild.GetMemberAsync(staffID);
- await staffMember.SendMessageAsync(message);
- }
- catch (NotFoundException)
- {
- }
- catch (UnauthorizedException)
- {
- }
- }
- }
+ try
+ {
+ DiscordMember staffMember = await guild.GetMemberAsync(staffID);
+ await staffMember.SendMessageAsync(message);
+ }
+ catch (NotFoundException)
+ {
+ }
+ catch (UnauthorizedException)
+ {
+ }
+ }
+ }
- // Log it if the log channel exists
- DiscordChannel logChannel = guild.GetChannel(Config.logChannel);
- if (logChannel != null)
- {
- DiscordEmbed logMessage = new DiscordEmbedBuilder
- {
- Color = DiscordColor.Green,
- Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".\n",
- Footer = new DiscordEmbedBuilder.EmbedFooter { Text = "Ticket " + ticketID }
- };
- await logChannel.SendMessageAsync(logMessage);
- }
- }
+ // Log it if the log channel exists
+ DiscordChannel logChannel = guild.GetChannel(Config.logChannel);
+ if (logChannel != null)
+ {
+ DiscordEmbed logMessage = new DiscordEmbedBuilder
+ {
+ Color = DiscordColor.Green,
+ Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".\n",
+ Footer = new DiscordEmbedBuilder.EmbedFooter {Text = "Ticket " + ticketID}
+ };
+ await logChannel.SendMessageAsync(logMessage);
+ }
+ }
- internal async Task OnMemberAdded(DiscordClient client, GuildMemberAddEventArgs e)
- {
- if (!Database.TryGetOpenTickets(e.Member.Id, out List ownTickets))
- {
- return;
- }
+ internal async Task OnMemberAdded(DiscordClient client, GuildMemberAddEventArgs e)
+ {
+ if (!Database.TryGetOpenTickets(e.Member.Id, out List ownTickets))
+ {
+ return;
+ }
- foreach (Database.Ticket ticket in ownTickets)
- {
- try
- {
- DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
- if (channel?.GuildId == e.Guild.Id)
- {
- await channel.AddOverwriteAsync(e.Member, Permissions.AccessChannels, Permissions.None);
- DiscordEmbed message = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Green)
- .WithDescription("User '" + e.Member.Username + "#" + e.Member.Discriminator + "' has rejoined the server, and has been re-added to the ticket.");
- await channel.SendMessageAsync(message);
- }
- }
- catch (Exception) { }
- }
- }
+ foreach (Database.Ticket ticket in ownTickets)
+ {
+ try
+ {
+ DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
+ if (channel?.GuildId == e.Guild.Id)
+ {
+ await channel.AddOverwriteAsync(e.Member, Permissions.AccessChannels, Permissions.None);
+ DiscordEmbed message = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Green)
+ .WithDescription("User '" + e.Member.Username + "#" + e.Member.Discriminator + "' has rejoined the server, and has been re-added to the ticket.");
+ await channel.SendMessageAsync(message);
+ }
+ }
+ catch (Exception) { }
+ }
+ }
- internal async Task OnMemberRemoved(DiscordClient client, GuildMemberRemoveEventArgs e)
- {
- if (Database.TryGetOpenTickets(e.Member.Id, out List ownTickets))
- {
- foreach (Database.Ticket ticket in ownTickets)
- {
- try
- {
- DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
- if (channel?.GuildId == e.Guild.Id)
- {
- DiscordEmbed message = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Red)
- .WithDescription("User '" + e.Member.Username + "#" + e.Member.Discriminator + "' has left the server.");
- await channel.SendMessageAsync(message);
- }
- }
- catch (Exception) { }
- }
- }
+ internal async Task OnMemberRemoved(DiscordClient client, GuildMemberRemoveEventArgs e)
+ {
+ if (Database.TryGetOpenTickets(e.Member.Id, out List ownTickets))
+ {
+ foreach(Database.Ticket ticket in ownTickets)
+ {
+ try
+ {
+ DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
+ if (channel?.GuildId == e.Guild.Id)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Red)
+ .WithDescription("User '" + e.Member.Username + "#" + e.Member.Discriminator + "' has left the server.");
+ await channel.SendMessageAsync(message);
+ }
+ }
+ catch (Exception) { }
+ }
+ }
- if (Database.TryGetAssignedTickets(e.Member.Id, out List assignedTickets) && Config.logChannel != 0)
- {
- DiscordChannel logChannel = await client.GetChannelAsync(Config.logChannel);
- if (logChannel != null)
- {
+ if (Database.TryGetAssignedTickets(e.Member.Id, out List assignedTickets) && Config.logChannel != 0)
+ {
+ DiscordChannel logChannel = await client.GetChannelAsync(Config.logChannel);
+ if (logChannel != null)
+ {
- foreach (Database.Ticket ticket in assignedTickets)
- {
- try
- {
- DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
- if (channel?.GuildId == e.Guild.Id)
- {
- DiscordEmbed message = new DiscordEmbedBuilder()
- .WithColor(DiscordColor.Red)
- .WithDescription("Assigned staff member '" + e.Member.Username + "#" + e.Member.Discriminator + "' has left the server: <#" + channel.Id + ">");
- await logChannel.SendMessageAsync(message);
- }
- }
- catch (Exception) { }
- }
- }
- }
- }
+ foreach (Database.Ticket ticket in assignedTickets)
+ {
+ try
+ {
+ DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
+ if (channel?.GuildId == e.Guild.Id)
+ {
+ DiscordEmbed message = new DiscordEmbedBuilder()
+ .WithColor(DiscordColor.Red)
+ .WithDescription("Assigned staff member '" + e.Member.Username + "#" + e.Member.Discriminator + "' has left the server: <#" + channel.Id + ">");
+ await logChannel.SendMessageAsync(message);
+ }
+ }
+ catch (Exception) { }
+ }
+ }
+ }
+ }
- private string ParseFailedCheck(CheckBaseAttribute attr)
- {
- switch (attr)
- {
- case CooldownAttribute _:
- return "You cannot use do that so often!";
- case RequireOwnerAttribute _:
- return "Only the server owner can use that command!";
- case RequirePermissionsAttribute _:
- return "You don't have permission to do that!";
- case RequireRolesAttribute _:
- return "You do not have a required role!";
- case RequireUserPermissionsAttribute _:
- return "You don't have permission to do that!";
- case RequireNsfwAttribute _:
- return "This command can only be used in an NSFW channel!";
- default:
- return "Unknown Discord API error occured, please try again later.";
- }
- }
- }
-}
+ private string ParseFailedCheck(CheckBaseAttribute attr)
+ {
+ switch (attr)
+ {
+ case CooldownAttribute _:
+ return "You cannot use do that so often!";
+ case RequireOwnerAttribute _:
+ return "Only the server owner can use that command!";
+ case RequirePermissionsAttribute _:
+ return "You don't have permission to do that!";
+ case RequireRolesAttribute _:
+ return "You do not have a required role!";
+ case RequireUserPermissionsAttribute _:
+ return "You don't have permission to do that!";
+ case RequireNsfwAttribute _:
+ return "This command can only be used in an NSFW channel!";
+ default:
+ return "Unknown Discord API error occured, please try again later.";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/SupportChild/Properties/Resources.resx b/SupportChild/Properties/Resources.resx
index 2beadd9..8edc7ae 100644
--- a/SupportChild/Properties/Resources.resx
+++ b/SupportChild/Properties/Resources.resx
@@ -1,124 +1,124 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\default_config.yml;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- [base64 mime encoded string representing a byte array form of the .NET Framework object]
- This is a comment
-
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
-
- ..\default_config.yml;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
\ No newline at end of file
diff --git a/SupportChild/SupportChild.cs b/SupportChild/SupportChild.cs
index 9a75aad..3f3c1b2 100644
--- a/SupportChild/SupportChild.cs
+++ b/SupportChild/SupportChild.cs
@@ -25,7 +25,7 @@ namespace SupportChild
private async Task MainAsync()
{
instance = this;
-
+
Console.WriteLine("Starting SupportChild version " + GetVersion() + "...");
try
{
@@ -61,10 +61,10 @@ namespace SupportChild
this.discordClient.Dispose();
Console.WriteLine("Discord client disconnected.");
}
-
+
Console.WriteLine("Loading config \"" + Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "config.yml\"");
Config.LoadConfig();
-
+
// Check if token is unset
if (Config.token == "" || Config.token == "")
{
@@ -84,16 +84,16 @@ namespace SupportChild
Console.WriteLine("Could not set up database tables, please confirm connection settings, status of the server and permissions of MySQL user. Error: " + e);
throw;
}
-
+
Console.WriteLine("Setting up Discord client...");
-
+
// Checking log level
if (!Enum.TryParse(Config.logLevel, true, out LogLevel logLevel))
{
Console.WriteLine("Log level '" + Config.logLevel + "' invalid, using 'Information' instead.");
logLevel = LogLevel.Information;
}
-
+
// Setting up client configuration
DiscordConfiguration cfg = new DiscordConfiguration
{
@@ -103,11 +103,11 @@ namespace SupportChild
AutoReconnect = true,
Intents = DiscordIntents.All
};
-
+
this.discordClient = new DiscordClient(cfg);
-
+
this.eventHandler = new EventHandler(this.discordClient);
-
+
Console.WriteLine("Hooking events...");
this.discordClient.Ready += this.eventHandler.OnReady;
this.discordClient.GuildAvailable += this.eventHandler.OnGuildAvailable;
@@ -119,11 +119,11 @@ namespace SupportChild
{
this.discordClient.MessageReactionAdded += this.eventHandler.OnReactionAdded;
}
-
+
Console.WriteLine("Registering commands...");
commands = discordClient.UseCommandsNext(new CommandsNextConfiguration
{
- StringPrefixes = new[] { Config.prefix }
+ StringPrefixes = new []{ Config.prefix }
});
this.commands.RegisterCommands();
@@ -160,4 +160,4 @@ namespace SupportChild
await this.discordClient.ConnectAsync();
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/SupportChild.csproj b/SupportChild/SupportChild.csproj
index 3702a8a..5b31187 100644
--- a/SupportChild/SupportChild.csproj
+++ b/SupportChild/SupportChild.csproj
@@ -1,70 +1,70 @@
-
-
-
- Exe
- ellie_icon.ico
- net6.0
- win-x64;linux-x64
- 1.2.0
- SupportChild.SupportChild
- EmotionChild
-
- https://github.com/EmotionChild/SupportChild
- https://github.com/EmotionChild/SupportChild
- Git
- LICENSE
- https://cdn.emotionchild.com/Ellie.png
- A Discord support bot build for the Ellie's Home Discord server
- 2.6.1.1
- 2.6.1.1
- en
- 1.2.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Resources.resx
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
+
-
-
- True
-
-
-
+
+ Exe
+ ellie_icon.ico
+ net6.0
+ win-x64;linux-x64
+ 1.2.0
+ SupportChild.SupportChild
+ EmotionChild
+
+ https://github.com/EmotionChild/SupportChild
+ https://github.com/EmotionChild/SupportChild
+ Git
+ LICENSE
+ https://cdn.emotionchild.com/Ellie.png
+ A Discord support bot build for the Ellie's Home Discord server
+ 2.6.1.1
+ 2.6.1.1
+ en
+ 1.2.0
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- lib\DiscordChatExporter.Core.dll
-
-
+
+
+ True
+ True
+ Resources.resx
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+
+
+ True
+
+
+
+
+
+
+
+
+
+
+ lib\DiscordChatExporter.Core.dll
+
+
diff --git a/SupportChild/Transcriber.cs b/SupportChild/Transcriber.cs
index 8ab68af..9b10e62 100644
--- a/SupportChild/Transcriber.cs
+++ b/SupportChild/Transcriber.cs
@@ -59,4 +59,4 @@ namespace SupportChild
return "ticket-" + ticketNumber.ToString("00000") + ".html";
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/Utilities.cs b/SupportChild/Utilities.cs
index dce74be..06099d1 100644
--- a/SupportChild/Utilities.cs
+++ b/SupportChild/Utilities.cs
@@ -15,8 +15,8 @@ namespace SupportChild
{
byte[] box = new byte[1];
do provider.GetBytes(box);
- while (!(box[0] < n * (byte.MaxValue / n)));
- int k = box[0] % n;
+ while (!(box[0] < n * (Byte.MaxValue / n)));
+ int k = (box[0] % n);
n--;
T value = list[k];
list[k] = list[n];
@@ -32,11 +32,11 @@ namespace SupportChild
{
return new string[0];
}
- return args.Trim().Replace("<@!", "").Replace("<@", "").Replace(">", "").Split();
+ return args.Trim().Replace("<@!", "").Replace("<@", "").Replace(">", "").Split();
}
public static LinkedList ParseListIntoMessages(List listItems)
- {
+ {
LinkedList messages = new LinkedList();
foreach (string listItem in listItems)
@@ -68,4 +68,4 @@ namespace SupportChild
return null;
}
}
-}
+}
\ No newline at end of file
diff --git a/SupportChild/default_config.yml b/SupportChild/default_config.yml
index 4386e1d..8dcb6e8 100644
--- a/SupportChild/default_config.yml
+++ b/SupportChild/default_config.yml
@@ -1,84 +1,84 @@
-bot:
- # Bot token.
- token: ""
- # Command prefix.
- prefix: "-"
- # Channel where ticket logs are posted (recommended)
- log-channel: 000000000000000000
- # Category where the ticket will be created, it will have the same permissions of that ticket plus read permissions for the user opening the ticket (recommended)
- ticket-category: 000000000000000000
- # A message which will open new tickets when users react to it (optional)
- reaction-message: 000000000000000000
- # Message posted when a ticket is opened.
- welcome-message: "Please describe your issue below, and include all information needed for us to help you."
- # Decides what messages are shown in console
- # Possible values are: Critical, Error, Warning, Information, Debug.
- console-log-level: "Information"
- # Format for timestamps in transcripts and google sheets if used
- timestamp-format: "yyyy-MM-dd HH:mm"
- # Whether or not 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.
- # This can be useful if you have admins set as inactive to not automatically recieve tickets and then have moderators elevate tickets when needed.
- random-assign-role-override: true
- # Sets the type of activity for the bot to display in its presence status
- # Possible values are: Playing, Streaming, ListeningTo, Watching, Competing
- presence-type: "ListeningTo"
- # Sets the activity text shown in the bot's status
- presence-text: "-new"
+bot:
+ # Bot token.
+ token: ""
+ # Command prefix.
+ prefix: "-"
+ # Channel where ticket logs are posted (recommended)
+ log-channel: 000000000000000000
+ # Category where the ticket will be created, it will have the same permissions of that ticket plus read permissions for the user opening the ticket (recommended)
+ ticket-category: 000000000000000000
+ # A message which will open new tickets when users react to it (optional)
+ reaction-message: 000000000000000000
+ # Message posted when a ticket is opened.
+ welcome-message: "Please describe your issue below, and include all information needed for us to help you."
+ # Decides what messages are shown in console
+ # Possible values are: Critical, Error, Warning, Information, Debug.
+ console-log-level: "Information"
+ # Format for timestamps in transcripts and google sheets if used
+ timestamp-format: "yyyy-MM-dd HH:mm"
+ # Whether or not 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.
+ # This can be useful if you have admins set as inactive to not automatically recieve tickets and then have moderators elevate tickets when needed.
+ random-assign-role-override: true
+ # Sets the type of activity for the bot to display in its presence status
+ # Possible values are: Playing, Streaming, ListeningTo, Watching, Competing
+ presence-type: "ListeningTo"
+ # Sets the activity text shown in the bot's status
+ presence-text: "-new"
notifications:
- # Notifies the assigned staff member when a new message is posted in a ticket if the ticket has been silent for a configurable amount of time
- # Other staff members and bots do not trigger this.
- ticket-updated: true
- # The above notification will only be sent if the ticket has been silent for more than this amount of days. Default is 0.5 days.
- ticket-updated-delay: 0.5
- # Notifies staff when they are assigned to tickets
- assignment: true
- # Notifies the user opening the ticket that their ticket was closed and includes the transcript
- closing: true
+ # Notifies the assigned staff member when a new message is posted in a ticket if the ticket has been silent for a configurable amount of time
+ # Other staff members and bots do not trigger this.
+ ticket-updated: true
+ # The above notification will only be sent if the ticket has been silent for more than this amount of days. Default is 0.5 days.
+ ticket-updated-delay: 0.5
+ # Notifies staff when they are assigned to tickets
+ assignment: true
+ # Notifies the user opening the ticket that their ticket was closed and includes the transcript
+ closing: true
database:
- # Address and port of the mysql server
- address: "127.0.0.1"
- port: 3306
- # Name of the database to use
- name: "supportbot"
- # Username and password for authentication
- user: ""
- password: ""
+ # Address and port of the mysql server
+ address: "127.0.0.1"
+ port: 3306
+ # Name of the database to use
+ name: "supportchild"
+ # Username and password for authentication
+ user: ""
+ password: ""
# Set up which roles are allowed to use different commands.
# Example:
# new: [ 000000000000000000, 111111111111111111 ]
# They are grouped into suggested command groups below for first time setup.
permissions:
- # Public commands
- close: []
- list: []
- new: []
- say: []
- status: []
- summary: []
- transcript: []
- # Moderator commands
- add: []
- addmessage: []
- assign: []
- blacklist: []
- listassigned: []
- listoldest: []
- listunassigned: []
- move: []
- rassign: []
- removemessage: []
- setsummary: []
- toggleactive: []
- unassign: []
- unblacklist: []
- # Admin commands
- addstaff: []
- reload: []
- removestaff: []
- setticket: []
- unsetticket: []
\ No newline at end of file
+ # Public commands
+ close: []
+ list: []
+ new: []
+ say: []
+ status: []
+ summary: []
+ transcript: []
+ # Moderator commands
+ add: []
+ addmessage: []
+ assign: []
+ blacklist: []
+ listassigned: []
+ listoldest: []
+ listunassigned: []
+ move: []
+ rassign: []
+ removemessage: []
+ setsummary: []
+ toggleactive: []
+ unassign: []
+ unblacklist: []
+ # Admin commands
+ addstaff: []
+ reload: []
+ removestaff: []
+ setticket: []
+ unsetticket: []
\ No newline at end of file