Update time!

This commit is contained in:
EmotionChild 2022-04-18 22:52:03 +12:00
parent 58a9c0f842
commit 6a39ece053
No known key found for this signature in database
GPG key ID: 23DC06AC32786520
35 changed files with 2902 additions and 2892 deletions

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.CommandsNext;

View file

@ -1,4 +1,4 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.Extensions.Logging;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;

View file

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
@ -10,11 +10,11 @@ namespace SupportChild.Commands
{
public class BlacklistCommand : BaseCommandModule
{
[Command("balcklist")]
[Command("blacklist")]
[Description("Blacklists a user from opening tickets.")]
public async Task OnExecute(CommandContext command, [RemainingText] string commandArgs)
{
// Check is the user has permission to use this command.
// Check if the user has permission to use this command.
if (!Config.HasPermission(command.Member, "blacklist"))
{
DiscordEmbed error = new DiscordEmbedBuilder
@ -79,6 +79,7 @@ namespace SupportChild.Commands
Color = DiscordColor.Green,
Description = blacklistedUser.Mention + " was blacklisted from opening tickets by " + command.Member.Mention + "."
};
await logChannel.SendMessageAsync(logMessage);
}
}
catch (Exception)

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
@ -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

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -13,7 +13,7 @@ namespace SupportChild.Commands
public class MoveCommand : BaseCommandModule
{
[Command("move")]
[Description("Move a ticket to another category.")]
[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.

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using DSharpPlus;
using DSharpPlus.CommandsNext;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;

View file

@ -1,4 +1,4 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.Extensions.Logging;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;

View file

@ -1,4 +1,4 @@
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
using Microsoft.Extensions.Logging;
@ -11,7 +11,7 @@ namespace SupportChild.Commands
public class SayCommand : BaseCommandModule
{
[Command("say")]
[Cooldown(1, 2, CooldownBucketType.User)]
[Cooldown(1, 2, CooldownBucketType.Channel)]
[Description("Prints a message with information from staff.")]
public async Task OnExecute(CommandContext command, string identifier)
{

View file

@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
@ -39,13 +39,13 @@ namespace SupportChild.Commands
return;
}
string sumarry = command.Message.Content.Replace(Config.prefix + "setsummary", "").Trim();
string summary = command.Message.Content.Replace(Config.prefix + "setsummary", "").Trim();
using (MySqlConnection c = Database.GetConnection())
{
c.Open();
MySqlCommand update = new MySqlCommand(@"UPDATE tickets SET summary = @summary WHERE channel_id = @channel_id", c);
update.Parameters.AddWithValue("@summary", sumarry);
update.Parameters.AddWithValue("@summary", summary);
update.Parameters.AddWithValue("@channel_id", channelID);
update.Prepare();
update.ExecuteNonQuery();

View file

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;

View file

@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;
@ -29,7 +29,7 @@ namespace SupportChild.Commands
long closedTickets = Database.GetNumberOfClosedTickets();
DiscordEmbed botInfo = new DiscordEmbedBuilder()
.WithAuthor("EmotionChild/SupportChild @ GitHub", "https://github.com/EmotionChild/SupportChild", "https://cdn.discordapp.com/attachments/765441543100170271/919729931922051072/Ellise_Concept_2.png")
.WithAuthor("EmotionChild/SupportChild @ GitHub", "https://github.com/EmotionChild/SupportChild", "https://cdn.emotionchild.com/Ellie.png")
.WithTitle("Bot information")
.WithColor(DiscordColor.Cyan)
.AddField("Version:", SupportChild.GetVersion(), false)

View file

@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;

View file

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
@ -68,7 +68,7 @@ namespace SupportChild.Commands
DiscordEmbed message = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
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);

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
@ -25,7 +25,7 @@ namespace SupportChild.Commands
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 but did not have permission.");
command.Client.Logger.Log(LogLevel.Information, "User tried to use the transcript command but did not have permission.");
return;
}
@ -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

@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
@ -11,7 +11,7 @@ namespace SupportChild.Commands
public class UnblacklistCommand : BaseCommandModule
{
[Command("unblacklist")]
[Description("Un-blacklists a user from from opening tickets.")]
[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.
@ -84,7 +84,7 @@ namespace SupportChild.Commands
}
catch (Exception)
{
DiscordEmbed message = new DiscordEmbedBuilder()
DiscordEmbed message = new DiscordEmbedBuilder
{
Color = DiscordColor.Red,
Description = "Error occured while removing " + blacklistedUser.Mention + " from blacklist."

View file

@ -1,4 +1,4 @@
using System.Threading.Tasks;
using System.Threading.Tasks;
using DSharpPlus.CommandsNext;
using DSharpPlus.CommandsNext.Attributes;
using DSharpPlus.Entities;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Collections.Generic;
using MySql.Data.MySqlClient;
@ -647,17 +647,17 @@ namespace SupportChild
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");
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 string FormattedCreatedTime()
{
return this.createdTime.ToString(Config.timestampFormat);
return createdTime.ToString(Config.timestampFormat);
}
}
public class StaffMember
@ -668,9 +668,9 @@ namespace SupportChild
public StaffMember(MySqlDataReader reader)
{
this.userID = reader.GetUInt64("user_id");
this.name = reader.GetString("name");
this.active = reader.GetBoolean("active");
userID = reader.GetUInt64("user_id");
name = reader.GetString("name");
active = reader.GetBoolean("active");
}
}
@ -682,9 +682,9 @@ namespace SupportChild
public Message(MySqlDataReader reader)
{
this.identifier = reader.GetString("identifier");
this.userID = reader.GetUInt64("user_id");
this.message = reader.GetString("message");
identifier = reader.GetString("identifier");
userID = reader.GetUInt64("user_id");
message = reader.GetString("message");
}
}
}

View file

@ -21,7 +21,7 @@ namespace SupportChild
public EventHandler(DiscordClient client)
{
this.discordClient = client;
discordClient = client;
}
internal Task OnReady(DiscordClient client, ReadyEventArgs e)
@ -35,7 +35,7 @@ namespace SupportChild
activityType = ActivityType.Playing;
}
this.discordClient.UpdateStatusAsync(new DiscordActivity(Config.presenceText, activityType), UserStatus.Online);
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 = this.ParseFailedCheck(attr)
Description = ParseFailedCheck(attr)
};
e.Context?.Channel?.SendMessageAsync(error);
}

View file

@ -53,6 +53,7 @@
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

View file

@ -29,7 +29,7 @@ namespace SupportChild
Console.WriteLine("Starting SupportChild version " + GetVersion() + "...");
try
{
this.Reload();
Reload();
// Block this task until the program is closed.
await Task.Delay(-1);
@ -55,10 +55,10 @@ namespace SupportChild
public async void Reload()
{
if (this.discordClient != null)
if (discordClient != null)
{
await this.discordClient.DisconnectAsync();
this.discordClient.Dispose();
await discordClient.DisconnectAsync();
discordClient.Dispose();
Console.WriteLine("Discord client disconnected.");
}
@ -104,20 +104,20 @@ namespace SupportChild
Intents = DiscordIntents.All
};
this.discordClient = new DiscordClient(cfg);
discordClient = new DiscordClient(cfg);
this.eventHandler = new EventHandler(this.discordClient);
eventHandler = new EventHandler(discordClient);
Console.WriteLine("Hooking events...");
this.discordClient.Ready += this.eventHandler.OnReady;
this.discordClient.GuildAvailable += this.eventHandler.OnGuildAvailable;
this.discordClient.ClientErrored += this.eventHandler.OnClientError;
this.discordClient.MessageCreated += this.eventHandler.OnMessageCreated;
this.discordClient.GuildMemberAdded += this.eventHandler.OnMemberAdded;
this.discordClient.GuildMemberRemoved += this.eventHandler.OnMemberRemoved;
discordClient.Ready += eventHandler.OnReady;
discordClient.GuildAvailable += eventHandler.OnGuildAvailable;
discordClient.ClientErrored += eventHandler.OnClientError;
discordClient.MessageCreated += eventHandler.OnMessageCreated;
discordClient.GuildMemberAdded += eventHandler.OnMemberAdded;
discordClient.GuildMemberRemoved += eventHandler.OnMemberRemoved;
if (Config.reactionMessage != 0)
{
this.discordClient.MessageReactionAdded += this.eventHandler.OnReactionAdded;
discordClient.MessageReactionAdded += eventHandler.OnReactionAdded;
}
Console.WriteLine("Registering commands...");
@ -126,38 +126,38 @@ namespace SupportChild
StringPrefixes = new[] { Config.prefix }
});
this.commands.RegisterCommands<AddCommand>();
this.commands.RegisterCommands<AddMessageCommand>();
this.commands.RegisterCommands<AddStaffCommand>();
this.commands.RegisterCommands<AssignCommand>();
this.commands.RegisterCommands<BlacklistCommand>();
this.commands.RegisterCommands<CloseCommand>();
this.commands.RegisterCommands<ListAssignedCommand>();
this.commands.RegisterCommands<ListCommand>();
this.commands.RegisterCommands<ListOldestCommand>();
this.commands.RegisterCommands<ListUnassignedCommand>();
this.commands.RegisterCommands<MoveCommand>();
this.commands.RegisterCommands<NewCommand>();
this.commands.RegisterCommands<RandomAssignCommand>();
this.commands.RegisterCommands<ReloadCommand>();
this.commands.RegisterCommands<RemoveMessageCommand>();
this.commands.RegisterCommands<RemoveStaffCommand>();
this.commands.RegisterCommands<SayCommand>();
this.commands.RegisterCommands<SetSummaryCommand>();
this.commands.RegisterCommands<SetTicketCommand>();
this.commands.RegisterCommands<StatusCommand>();
this.commands.RegisterCommands<SummaryCommand>();
this.commands.RegisterCommands<ToggleActiveCommand>();
this.commands.RegisterCommands<TranscriptCommand>();
this.commands.RegisterCommands<UnassignCommand>();
this.commands.RegisterCommands<UnblacklistCommand>();
this.commands.RegisterCommands<UnsetTicketCommand>();
commands.RegisterCommands<AddCommand>();
commands.RegisterCommands<AddMessageCommand>();
commands.RegisterCommands<AddStaffCommand>();
commands.RegisterCommands<AssignCommand>();
commands.RegisterCommands<BlacklistCommand>();
commands.RegisterCommands<CloseCommand>();
commands.RegisterCommands<ListAssignedCommand>();
commands.RegisterCommands<ListCommand>();
commands.RegisterCommands<ListOldestCommand>();
commands.RegisterCommands<ListUnassignedCommand>();
commands.RegisterCommands<MoveCommand>();
commands.RegisterCommands<NewCommand>();
commands.RegisterCommands<RandomAssignCommand>();
commands.RegisterCommands<ReloadCommand>();
commands.RegisterCommands<RemoveMessageCommand>();
commands.RegisterCommands<RemoveStaffCommand>();
commands.RegisterCommands<SayCommand>();
commands.RegisterCommands<SetSummaryCommand>();
commands.RegisterCommands<SetTicketCommand>();
commands.RegisterCommands<StatusCommand>();
commands.RegisterCommands<SummaryCommand>();
commands.RegisterCommands<ToggleActiveCommand>();
commands.RegisterCommands<TranscriptCommand>();
commands.RegisterCommands<UnassignCommand>();
commands.RegisterCommands<UnblacklistCommand>();
commands.RegisterCommands<UnsetTicketCommand>();
Console.WriteLine("Hooking command events...");
this.commands.CommandErrored += this.eventHandler.OnCommandError;
commands.CommandErrored += eventHandler.OnCommandError;
Console.WriteLine("Connecting to Discord...");
await this.discordClient.ConnectAsync();
await discordClient.ConnectAsync();
}
}
}

View file

@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<ApplicationIcon>ellie_icon.ico</ApplicationIcon>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifiers>win-x64;linux-x64</RuntimeIdentifiers>
<Version>1.1.0</Version>
<Version>1.2.0</Version>
<StartupObject>SupportChild.SupportChild</StartupObject>
<Authors>EmotionChild</Authors>
<Product />
@ -13,17 +13,18 @@
<RepositoryUrl>https://github.com/EmotionChild/SupportChild</RepositoryUrl>
<RepositoryType>Git</RepositoryType>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageIconUrl></PackageIconUrl>
<PackageIconUrl>https://cdn.emotionchild.com/Ellie.png</PackageIconUrl>
<Description>A Discord support bot build for the Ellie's Home Discord server</Description>
<AssemblyVersion>2.5.0.0</AssemblyVersion>
<FileVersion>2.5.0.0</FileVersion>
<AssemblyVersion>2.6.1.1</AssemblyVersion>
<FileVersion>2.6.1.1</FileVersion>
<NeutralLanguage>en</NeutralLanguage>
<PackageVersion>1.2.0</PackageVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DSharpPlus" Version="4.1.0" />
<PackageReference Include="DSharpPlus.CommandsNext" Version="4.1.0" />
<PackageReference Include="DSharpPlus.Interactivity" Version="4.1.0" />
<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="JsonExtensions" Version="1.2.0" />
<PackageReference Include="MiniRazor.CodeGen" Version="2.2.1" />
<PackageReference Include="MySql.Data" Version="8.0.28" />
@ -49,6 +50,13 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="lib\" />
</ItemGroup>

View file

@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using System.Threading.Tasks;
using DiscordChatExporter.Core.Discord;

View file

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using DSharpPlus.Entities;
@ -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

@ -2,7 +2,7 @@ bot:
# Bot token.
token: "<add-token-here>"
# Command prefix.
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)
@ -25,7 +25,7 @@ bot:
# Possible values are: Playing, Streaming, ListeningTo, Watching, Competing
presence-type: "ListeningTo"
# Sets the activity text shown in the bot's status
presence-text: "+new"
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