1.2.0 update

Updated and fixed some stuff
This commit is contained in:
Emotion 2022-05-20 02:06:32 +12:00 committed by GitHub
commit 8f2f03a99b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 3019 additions and 3018 deletions

View file

@ -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. # package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options: # Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
@ -12,7 +12,7 @@ updates:
open-pull-requests-limit: 5 open-pull-requests-limit: 5
reviewers: reviewers:
- EmotionChild - EmotionChild
target-branch: "main" target-branch: "development"
labels: labels:
- "nuget" - "nuget"
- "dependencies" - "dependencies"

View file

@ -1,4 +1,4 @@
name: .NET name: .NET
on: on:
push: push:

3
.gitignore vendored
View file

@ -362,5 +362,8 @@ MigrationBackup/
# Fody - auto-generated XML schema # Fody - auto-generated XML schema
FodyWeavers.xsd FodyWeavers.xsd
# Manually added folders
Windows-x64/ Windows-x64/
Linux-x64/ Linux-x64/
.idea
.vs

View file

@ -1 +1,3 @@
# SupportChild # 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!

View file

@ -1,9 +1,6 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SupportChild", "SupportChild\SupportChild.csproj", "{B043AACB-D763-4C61-9524-C8B7C58DA3EF}"
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}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +8,9 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9124DF58-D261-4906-8ECA-D853DEBE07D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9124DF58-D261-4906-8ECA-D853DEBE07D4}.Debug|Any CPU.Build.0 = Debug|Any CPU {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9124DF58-D261-4906-8ECA-D853DEBE07D4}.Release|Any CPU.ActiveCfg = Release|Any CPU {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9124DF58-D261-4906-8ECA-D853DEBE07D4}.Release|Any CPU.Build.0 = Release|Any CPU {B043AACB-D763-4C61-9524-C8B7C58DA3EF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B2CD3447-A8BA-4B02-9E08-A75CBBD2BDCB}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -0,0 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/PencilsConfiguration/ActualSeverity/@EntryValue">ERROR</s:String>
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=SupportChild_002FProperties_002FResources/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean>
</wpf:ResourceDictionary>

View file

@ -51,7 +51,7 @@ namespace SupportChild.Commands
return; return;
} }
if (Database.AddMessage(identifier, command.Member.Id, message)) if(Database.AddMessage(identifier, command.Member.Id, message))
{ {
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {
@ -71,7 +71,6 @@ namespace SupportChild.Commands
await command.RespondAsync(error); await command.RespondAsync(error);
return; return;
} }
} }
} }
} }

View file

@ -115,7 +115,7 @@ namespace SupportChild.Commands
}; };
await staffMember.SendMessageAsync(message); await staffMember.SendMessageAsync(message);
} }
catch (UnauthorizedException) { } catch (UnauthorizedException) {}
} }

View file

@ -35,7 +35,7 @@ namespace SupportChild.Commands
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {
Color = DiscordColor.Red, Color = DiscordColor.Red,
Description = "Invalid list amount. (Must be an integer between 5 and 100)" Description = "Invalid list amount. (Must be integer between 5 and 100)"
}; };
await command.RespondAsync(error); await command.RespondAsync(error);
return; return;

View file

@ -121,8 +121,8 @@ namespace SupportChild.Commands
DiscordMember staffMember = await command.Guild.GetMemberAsync(staffID); DiscordMember staffMember = await command.Guild.GetMemberAsync(staffID);
await staffMember.SendMessageAsync(message); await staffMember.SendMessageAsync(message);
} }
catch (NotFoundException) { } catch (NotFoundException) {}
catch (UnauthorizedException) { } catch (UnauthorizedException) {}
} }
} }
@ -141,7 +141,7 @@ namespace SupportChild.Commands
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket " + ticketChannel.Mention + " opened by " + command.Member.Mention + ".\n", Description = "Ticket " + ticketChannel.Mention + " opened by " + command.Member.Mention + ".\n",
Footer = new DiscordEmbedBuilder.EmbedFooter { Text = "Ticket " + ticketID } Footer = new DiscordEmbedBuilder.EmbedFooter {Text = "Ticket " + ticketID}
}; };
await logChannel.SendMessageAsync(logMessage); await logChannel.SendMessageAsync(logMessage);
} }

View file

@ -80,7 +80,7 @@ namespace SupportChild.Commands
}; };
await staffMember.SendMessageAsync(message); await staffMember.SendMessageAsync(message);
} }
catch (UnauthorizedException) { } catch (UnauthorizedException) {}
} }
// Log it if the log channel exists // Log it if the log channel exists

View file

@ -40,7 +40,7 @@ namespace SupportChild.Commands
return; return;
} }
if (Database.RemoveMessage(identifier)) if(Database.RemoveMessage(identifier))
{ {
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {

View file

@ -8,7 +8,7 @@ using MySql.Data.MySqlClient;
namespace SupportChild.Commands namespace SupportChild.Commands
{ {
public class SetTicketCommand : BaseCommandModule public class SetTicketCommand :BaseCommandModule
{ {
[Command("setticket")] [Command("setticket")]
[Description("Turns a channel into a ticket, warning: this will let anyone with write access delete the channel using the close command.")] [Description("Turns a channel into a ticket, warning: this will let anyone with write access delete the channel using the close command.")]

View file

@ -98,7 +98,7 @@ namespace SupportChild.Commands
} }
// 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. // 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)) else if (!Database.TryGetClosedTicket(ticketID, out ticket) || (ticket?.creatorID != command.Member.Id && !Database.IsStaff(command.Member.Id)))
{ {
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {

View file

@ -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);
}
}
}
}

View file

@ -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);
}
}
}
}

View file

@ -21,7 +21,7 @@ namespace SupportChild
internal static string logLevel = "Information"; internal static string logLevel = "Information";
internal static string timestampFormat = "yyyy-MMM-dd HH:mm"; internal static string timestampFormat = "yyyy-MMM-dd HH:mm";
internal static bool randomAssignment = false; internal static bool randomAssignment = false;
internal static bool randomAssignRoleOverride = false; // TODO: Implement internal static bool randomAssignRoleOverride = false;
internal static string presenceType = "Playing"; internal static string presenceType = "Playing";
internal static string presenceText = ""; internal static string presenceText = "";
@ -110,8 +110,8 @@ namespace SupportChild
// Reads database info // Reads database info
hostName = json.SelectToken("database.address")?.Value<string>() ?? ""; hostName = json.SelectToken("database.address")?.Value<string>() ?? "";
port = json.SelectToken("database.port")?.Value<int>() ?? 3306; port = json.SelectToken("database.port")?.Value<int>() ?? 3306;
database = json.SelectToken("database.name")?.Value<string>() ?? "supportbot"; database = json.SelectToken("database.name")?.Value<string>() ?? "supportchild";
username = json.SelectToken("database.user")?.Value<string>() ?? "supportbot"; username = json.SelectToken("database.user")?.Value<string>() ?? "supportchild";
password = json.SelectToken("database.password")?.Value<string>() ?? ""; password = json.SelectToken("database.password")?.Value<string>() ?? "";
timestampFormat = timestampFormat.Trim(); timestampFormat = timestampFormat.Trim();

View file

@ -647,17 +647,17 @@ namespace SupportChild
public Ticket(MySqlDataReader reader) public Ticket(MySqlDataReader reader)
{ {
id = reader.GetUInt32("id"); this.id = reader.GetUInt32("id");
createdTime = reader.GetDateTime("created_time"); this.createdTime = reader.GetDateTime("created_time");
creatorID = reader.GetUInt64("creator_id"); this.creatorID = reader.GetUInt64("creator_id");
assignedStaffID = reader.GetUInt64("assigned_staff_id"); this.assignedStaffID = reader.GetUInt64("assigned_staff_id");
summary = reader.GetString("summary"); this.summary = reader.GetString("summary");
channelID = reader.GetUInt64("channel_id"); this.channelID = reader.GetUInt64("channel_id");
} }
public string FormattedCreatedTime() public string FormattedCreatedTime()
{ {
return createdTime.ToString(Config.timestampFormat); return this.createdTime.ToString(Config.timestampFormat);
} }
} }
public class StaffMember public class StaffMember
@ -668,9 +668,9 @@ namespace SupportChild
public StaffMember(MySqlDataReader reader) public StaffMember(MySqlDataReader reader)
{ {
userID = reader.GetUInt64("user_id"); this.userID = reader.GetUInt64("user_id");
name = reader.GetString("name"); this.name = reader.GetString("name");
active = reader.GetBoolean("active"); this.active = reader.GetBoolean("active");
} }
} }
@ -682,9 +682,9 @@ namespace SupportChild
public Message(MySqlDataReader reader) public Message(MySqlDataReader reader)
{ {
identifier = reader.GetString("identifier"); this.identifier = reader.GetString("identifier");
userID = reader.GetUInt64("user_id"); this.userID = reader.GetUInt64("user_id");
message = reader.GetString("message"); this.message = reader.GetString("message");
} }
} }
} }

View file

@ -21,7 +21,7 @@ namespace SupportChild
public EventHandler(DiscordClient client) public EventHandler(DiscordClient client)
{ {
discordClient = client; this.discordClient = client;
} }
internal Task OnReady(DiscordClient client, ReadyEventArgs e) internal Task OnReady(DiscordClient client, ReadyEventArgs e)
@ -35,7 +35,7 @@ namespace SupportChild
activityType = ActivityType.Playing; activityType = ActivityType.Playing;
} }
discordClient.UpdateStatusAsync(new DiscordActivity(Config.presenceText, activityType), UserStatus.Online); this.discordClient.UpdateStatusAsync(new DiscordActivity(Config.presenceText, activityType), UserStatus.Online);
return Task.CompletedTask; return Task.CompletedTask;
} }
@ -105,7 +105,7 @@ namespace SupportChild
DiscordEmbed error = new DiscordEmbedBuilder DiscordEmbed error = new DiscordEmbedBuilder
{ {
Color = DiscordColor.Red, Color = DiscordColor.Red,
Description = ParseFailedCheck(attr) Description = this.ParseFailedCheck(attr)
}; };
e.Context?.Channel?.SendMessageAsync(error); e.Context?.Channel?.SendMessageAsync(error);
} }
@ -206,7 +206,7 @@ namespace SupportChild
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".\n", Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".\n",
Footer = new DiscordEmbedBuilder.EmbedFooter { Text = "Ticket " + ticketID } Footer = new DiscordEmbedBuilder.EmbedFooter {Text = "Ticket " + ticketID}
}; };
await logChannel.SendMessageAsync(logMessage); await logChannel.SendMessageAsync(logMessage);
} }
@ -241,7 +241,7 @@ namespace SupportChild
{ {
if (Database.TryGetOpenTickets(e.Member.Id, out List<Database.Ticket> ownTickets)) if (Database.TryGetOpenTickets(e.Member.Id, out List<Database.Ticket> ownTickets))
{ {
foreach (Database.Ticket ticket in ownTickets) foreach(Database.Ticket ticket in ownTickets)
{ {
try try
{ {

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema

View file

@ -123,7 +123,7 @@ namespace SupportChild
Console.WriteLine("Registering commands..."); Console.WriteLine("Registering commands...");
commands = discordClient.UseCommandsNext(new CommandsNextConfiguration commands = discordClient.UseCommandsNext(new CommandsNextConfiguration
{ {
StringPrefixes = new[] { Config.prefix } StringPrefixes = new []{ Config.prefix }
}); });
this.commands.RegisterCommands<AddCommand>(); this.commands.RegisterCommands<AddCommand>();

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
@ -22,12 +22,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-01109" /> <PackageReference Include="DSharpPlus" Version="4.2.0" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0-nightly-01109" /> <PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-01109" /> <PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0" />
<PackageReference Include="JsonExtensions" Version="1.2.0" /> <PackageReference Include="JsonExtensions" Version="1.2.0" />
<PackageReference Include="MiniRazor.CodeGen" Version="2.2.1" /> <PackageReference Include="MiniRazor.CodeGen" Version="2.2.1" />
<PackageReference Include="MySql.Data" Version="8.0.28" /> <PackageReference Include="MySql.Data" Version="8.0.29" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Polly" Version="7.2.3" /> <PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="Superpower" Version="3.0.0" /> <PackageReference Include="Superpower" Version="3.0.0" />

View file

@ -15,8 +15,8 @@ namespace SupportChild
{ {
byte[] box = new byte[1]; byte[] box = new byte[1];
do provider.GetBytes(box); do provider.GetBytes(box);
while (!(box[0] < n * (byte.MaxValue / n))); while (!(box[0] < n * (Byte.MaxValue / n)));
int k = box[0] % n; int k = (box[0] % n);
n--; n--;
T value = list[k]; T value = list[k];
list[k] = list[n]; list[k] = list[n];

View file

@ -1,4 +1,4 @@
bot: bot:
# Bot token. # Bot token.
token: "<add-token-here>" token: "<add-token-here>"
# Command prefix. # Command prefix.
@ -43,7 +43,7 @@ database:
address: "127.0.0.1" address: "127.0.0.1"
port: 3306 port: 3306
# Name of the database to use # Name of the database to use
name: "supportbot" name: "supportchild"
# Username and password for authentication # Username and password for authentication
user: "" user: ""
password: "" password: ""