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.
# 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"

View file

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

3
.gitignore vendored
View file

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

View file

@ -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!

View file

@ -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

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

@ -71,7 +71,6 @@ namespace SupportChild.Commands
await command.RespondAsync(error);
return;
}
}
}
}

View file

@ -35,7 +35,7 @@ namespace SupportChild.Commands
DiscordEmbed error = new DiscordEmbedBuilder
{
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);
return;

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.
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
{

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 timestampFormat = "yyyy-MMM-dd HH:mm";
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 presenceText = "";
@ -110,8 +110,8 @@ namespace SupportChild
// Reads database info
hostName = json.SelectToken("database.address")?.Value<string>() ?? "";
port = json.SelectToken("database.port")?.Value<int>() ?? 3306;
database = json.SelectToken("database.name")?.Value<string>() ?? "supportbot";
username = json.SelectToken("database.user")?.Value<string>() ?? "supportbot";
database = json.SelectToken("database.name")?.Value<string>() ?? "supportchild";
username = json.SelectToken("database.user")?.Value<string>() ?? "supportchild";
password = json.SelectToken("database.password")?.Value<string>() ?? "";
timestampFormat = timestampFormat.Trim();

View file

@ -647,17 +647,17 @@ namespace SupportChild
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");
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);
return this.createdTime.ToString(Config.timestampFormat);
}
}
public class StaffMember
@ -668,9 +668,9 @@ namespace SupportChild
public StaffMember(MySqlDataReader reader)
{
userID = reader.GetUInt64("user_id");
name = reader.GetString("name");
active = reader.GetBoolean("active");
this.userID = reader.GetUInt64("user_id");
this.name = reader.GetString("name");
this.active = reader.GetBoolean("active");
}
}
@ -682,9 +682,9 @@ namespace SupportChild
public Message(MySqlDataReader reader)
{
identifier = reader.GetString("identifier");
userID = reader.GetUInt64("user_id");
message = reader.GetString("message");
this.identifier = reader.GetString("identifier");
this.userID = reader.GetUInt64("user_id");
this.message = reader.GetString("message");
}
}
}

View file

@ -21,7 +21,7 @@ namespace SupportChild
public EventHandler(DiscordClient client)
{
discordClient = client;
this.discordClient = client;
}
internal Task OnReady(DiscordClient client, ReadyEventArgs e)
@ -35,7 +35,7 @@ namespace SupportChild
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;
}
@ -105,7 +105,7 @@ namespace SupportChild
DiscordEmbed error = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = ParseFailedCheck(attr)
Description = this.ParseFailedCheck(attr)
};
e.Context?.Channel?.SendMessageAsync(error);
}

View file

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

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
@ -22,12 +22,12 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.2.0-nightly-01109" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0-nightly-01109" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0-nightly-01109" />
<PackageReference Include="DSharpPlus" Version="4.2.0" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.2.0" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.2.0" />
<PackageReference Include="JsonExtensions" Version="1.2.0" />
<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="Polly" Version="7.2.3" />
<PackageReference Include="Superpower" Version="3.0.0" />

View file

@ -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];

View file

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