From f5852dae29c820305a30b88e4f1b7e2a28efcb3d Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 27 Dec 2024 01:21:37 +1300 Subject: [PATCH] Added more detailed logging to log channel --- Commands/AddCategoryCommand.cs | 19 +++++++++ Commands/AddCommand.cs | 9 ++-- Commands/AddMessageCommand.cs | 19 +++++++++ Commands/AddStaffCommand.cs | 2 +- Commands/AdminCommands.cs | 45 +++++++++++++++++--- Commands/AssignCommand.cs | 6 ++- Commands/BlacklistCommand.cs | 4 +- Commands/CloseCommand.cs | 10 ++++- Commands/CreateButtonPanelCommand.cs | 15 +++++++ Commands/CreateSelectionBoxPanelCommand.cs | 15 +++++++ Commands/MoveCommand.cs | 20 ++++++++- Commands/NewCommand.cs | 11 ++--- Commands/RandomAssignCommand.cs | 6 ++- Commands/RemoveCategoryCommand.cs | 22 ++++++++-- Commands/RemoveMessageCommand.cs | 15 +++++++ Commands/RemoveStaffCommand.cs | 2 +- Commands/RestartInterviewCommand.cs | 31 +++++++++++++- Commands/SayCommand.cs | 15 +++++++ Commands/SetSummaryCommand.cs | 21 +++++++++- Commands/ToggleActiveCommand.cs | 48 ++++++++++++++++++++-- Commands/TranscriptCommand.cs | 7 +++- Commands/UnassignCommand.cs | 6 ++- Commands/UnblacklistCommand.cs | 4 +- 23 files changed, 316 insertions(+), 36 deletions(-) diff --git a/Commands/AddCategoryCommand.cs b/Commands/AddCategoryCommand.cs index 8dd8415..ac258b4 100644 --- a/Commands/AddCategoryCommand.cs +++ b/Commands/AddCategoryCommand.cs @@ -4,6 +4,7 @@ using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; @@ -72,5 +73,23 @@ public class AddCategoryCommand Description = "Error: Failed adding the category to the database." }, true); } + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " added `" + category.Name + "` to the category list.", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Category: " + title + } + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/AddCommand.cs b/Commands/AddCommand.cs index 3e56175..9bcd74c 100644 --- a/Commands/AddCommand.cs +++ b/Commands/AddCommand.cs @@ -18,7 +18,7 @@ public class AddCommand [Parameter("user")][Description("User to add to ticket.")] DiscordUser user) { // Check if ticket exists in the database - if (!Database.IsOpenTicket(command.Channel.Id)) + if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket)) { await command.RespondAsync(new DiscordEmbedBuilder { @@ -62,7 +62,6 @@ public class AddCommand Description = "Added " + member.Mention + " to ticket." }); - // Log it if the log channel exists try { DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); @@ -70,7 +69,11 @@ public class AddCommand { Color = DiscordColor.Green, Description = member.Mention + " was added to " + command.Channel.Mention + - " by " + command.Member?.Mention + "." + " by " + command.User.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }); } catch (NotFoundException) diff --git a/Commands/AddMessageCommand.cs b/Commands/AddMessageCommand.cs index 87d8c3f..0b7578a 100644 --- a/Commands/AddMessageCommand.cs +++ b/Commands/AddMessageCommand.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; @@ -52,5 +53,23 @@ public class AddMessageCommand Description = "Error: Failed adding the message to the database." }, true); } + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " added or updated `" + identifier + "` in the /say command.\n\nContent:\n\n" + message, + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Identifier: " + identifier + } + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/AddStaffCommand.cs b/Commands/AddStaffCommand.cs index 45b3f82..c4e4d03 100644 --- a/Commands/AddStaffCommand.cs +++ b/Commands/AddStaffCommand.cs @@ -65,7 +65,7 @@ public class AddStaffCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = staffMember.Mention + " was added to staff.\n" + Description = staffMember.Mention + " was added to staff by " + command.User.Mention + "." }); } catch (NotFoundException) diff --git a/Commands/AdminCommands.cs b/Commands/AdminCommands.cs index f621017..7e3ad14 100644 --- a/Commands/AdminCommands.cs +++ b/Commands/AdminCommands.cs @@ -115,11 +115,10 @@ public class AdminCommands DiscordUser ticketUser = (user == null ? command.User : user); long id = Database.NewTicket(ticketUser.Id, 0, command.Channel.Id); - string ticketID = id.ToString("00000"); await command.RespondAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = "Channel has been designated ticket " + ticketID + "." + Description = "Channel has been designated ticket " + id.ToString("00000") + "." }); try @@ -129,7 +128,11 @@ public class AdminCommands await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = command.Channel.Mention + " has been designated ticket " + ticketID + " by " + command.Member.Mention + "." + Description = command.Channel.Mention + " has been designated ticket " + id.ToString("00000") + " by " + command.Member?.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + id.ToString("00000") + } }); } catch (NotFoundException) @@ -189,7 +192,11 @@ public class AdminCommands await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = command.Channel.Mention + " has been undesignated as a ticket by " + command.Member.Mention + "." + Description = command.Channel.Mention + " has been undesignated as a ticket by " + command.User.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }); } catch (NotFoundException) @@ -217,6 +224,21 @@ public class AdminCommands Color = DiscordColor.Green, Description = "Reloading bot application..." }); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.Channel.Mention + " reloaded the bot.", + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } + Logger.Log("Reloading bot..."); await SupportChild.Reload(); } @@ -328,9 +350,22 @@ public class AdminCommands await command.RespondAsync(new DiscordEmbedBuilder { - Color = DiscordColor.Green, Description = "Uploaded interview template." }, true); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.Channel.Mention + " uploaded new interview templates.", + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/AssignCommand.cs b/Commands/AssignCommand.cs index bebd1ad..d619d7f 100644 --- a/Commands/AssignCommand.cs +++ b/Commands/AssignCommand.cs @@ -99,7 +99,11 @@ public class AssignCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = member.Mention + " was assigned to " + command.Channel.Mention + " by " + command.Member.Mention + "." + Description = member.Mention + " was assigned to " + command.Channel.Mention + " by " + command.User.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }); } catch (NotFoundException) diff --git a/Commands/BlacklistCommand.cs b/Commands/BlacklistCommand.cs index 55bca8b..2dfb18d 100644 --- a/Commands/BlacklistCommand.cs +++ b/Commands/BlacklistCommand.cs @@ -32,7 +32,7 @@ public class BlacklistCommand await command.RespondAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = "Blacklisted " + user.Mention + "." + Description = "Blocked " + user.Mention + " from opening new tickets." }, true); try @@ -42,7 +42,7 @@ public class BlacklistCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = user.Mention + " was blacklisted from opening tickets by " + command.Member.Mention + "." + Description = user.Mention + " was blocked from opening tickets by " + command.User.Mention + "." }); } catch (NotFoundException) diff --git a/Commands/CloseCommand.cs b/Commands/CloseCommand.cs index 07a12dd..436b72e 100644 --- a/Commands/CloseCommand.cs +++ b/Commands/CloseCommand.cs @@ -92,7 +92,10 @@ public class CloseCommand Color = DiscordColor.Green, Description = "Ticket " + ticket.id.ToString("00000") + " closed by " + interaction.User.Mention + ".\n" + closeReason, - Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + channelName } + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }; await using FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read); @@ -114,7 +117,10 @@ public class CloseCommand Color = DiscordColor.Green, Description = "Ticket " + ticket.id.ToString("00000") + " which you opened has now been closed, " + "check the transcript for more info.\n" + closeReason, - Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + channelName } + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }; try diff --git a/Commands/CreateButtonPanelCommand.cs b/Commands/CreateButtonPanelCommand.cs index 794b4c7..e8a18ac 100644 --- a/Commands/CreateButtonPanelCommand.cs +++ b/Commands/CreateButtonPanelCommand.cs @@ -6,6 +6,7 @@ using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; @@ -49,5 +50,19 @@ public class CreateButtonPanelCommand Color = DiscordColor.Green, Description = "Successfully created message, make sure to run this command again if you add new categories to the bot." }, true); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " created a new button panel in " + command.Channel.Mention + "." + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/CreateSelectionBoxPanelCommand.cs b/Commands/CreateSelectionBoxPanelCommand.cs index 4734b75..0a6e6e6 100644 --- a/Commands/CreateSelectionBoxPanelCommand.cs +++ b/Commands/CreateSelectionBoxPanelCommand.cs @@ -6,6 +6,7 @@ using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; @@ -27,6 +28,20 @@ public class CreateSelectionBoxPanelCommand Color = DiscordColor.Green, Description = "Successfully created message, make sure to run this command again if you add new categories to the bot." }, true); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " created a new selector panel in " + command.Channel.Mention + "." + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } public static async Task> GetSelectComponents(SlashCommandContext command, string placeholder) diff --git a/Commands/MoveCommand.cs b/Commands/MoveCommand.cs index 3c108be..98f2e5c 100644 --- a/Commands/MoveCommand.cs +++ b/Commands/MoveCommand.cs @@ -20,7 +20,7 @@ public class MoveCommand [Parameter("category")][Description("The category to move the ticket to. Only has to be the beginning of the name.")] string category) { // Check if ticket exists in the database - if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket _)) + if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket)) { await command.RespondAsync(new DiscordEmbedBuilder { @@ -83,5 +83,23 @@ public class MoveCommand Color = DiscordColor.Green, Description = "Ticket was moved to `" + categoryChannel.Name + "`." }); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " moved " + command.Channel.Mention + " to `" + categoryChannel.Name + "`.", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/NewCommand.cs b/Commands/NewCommand.cs index 089af54..137f197 100644 --- a/Commands/NewCommand.cs +++ b/Commands/NewCommand.cs @@ -166,11 +166,9 @@ public class NewCommand } long id = Database.NewTicket(member.Id, staffID, ticketChannel.Id); - string ticketID = id.ToString("00000"); - try { - await ticketChannel.ModifyAsync(modifiedAttributes => modifiedAttributes.Name = "ticket-" + ticketID); + await ticketChannel.ModifyAsync(modifiedAttributes => modifiedAttributes.Name = "ticket-" + id.ToString("00000")); } catch (DiscordException e) { @@ -245,8 +243,11 @@ public class NewCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".\n", - Footer = new DiscordEmbedBuilder.EmbedFooter { Text = "Ticket " + ticketID } + Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + id.ToString("00000") + } }); } catch (NotFoundException) diff --git a/Commands/RandomAssignCommand.cs b/Commands/RandomAssignCommand.cs index ad1b7b1..825c0ef 100644 --- a/Commands/RandomAssignCommand.cs +++ b/Commands/RandomAssignCommand.cs @@ -76,7 +76,11 @@ public class RandomAssignCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = staffMember.Mention + " was randomly assigned to " + command.Channel.Mention + " by " + command.Member.Mention + "." + Description = staffMember.Mention + " was randomly assigned to " + command.Channel.Mention + " by " + command.User.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }); } catch (NotFoundException) diff --git a/Commands/RemoveCategoryCommand.cs b/Commands/RemoveCategoryCommand.cs index 73f78f8..efc2b40 100644 --- a/Commands/RemoveCategoryCommand.cs +++ b/Commands/RemoveCategoryCommand.cs @@ -4,6 +4,7 @@ using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; @@ -13,9 +14,9 @@ public class RemoveCategoryCommand [Command("removecategory")] [Description("Removes the ability for users to open tickets in a specific category.")] public async Task OnExecute(SlashCommandContext command, - [Parameter("category")][Description("The category to remove.")] DiscordChannel channel) + [Parameter("category")][Description("The category to remove.")] DiscordChannel category) { - if (!Database.TryGetCategory(channel.Id, out Database.Category _)) + if (!Database.TryGetCategory(category.Id, out Database.Category _)) { await command.RespondAsync(new DiscordEmbedBuilder { @@ -25,7 +26,7 @@ public class RemoveCategoryCommand return; } - if (Database.RemoveCategory(channel.Id)) + if (Database.RemoveCategory(category.Id)) { await command.RespondAsync(new DiscordEmbedBuilder { @@ -41,5 +42,20 @@ public class RemoveCategoryCommand Description = "Error: Failed removing the category from the database." }, true); } + + try + { + // Log it if the log channel exists + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = "`" + category.Name + "` was removed by " + command.User.Mention + "." + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/RemoveMessageCommand.cs b/Commands/RemoveMessageCommand.cs index 8a011d1..112ed41 100644 --- a/Commands/RemoveMessageCommand.cs +++ b/Commands/RemoveMessageCommand.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; @@ -41,5 +42,19 @@ public class RemoveMessageCommand Description = "Error: Failed removing the message from the database." }, true); } + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = "`" + identifier + "` was removed from the /say command by " + command.User.Mention + "." + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/RemoveStaffCommand.cs b/Commands/RemoveStaffCommand.cs index b42b449..d94d9dd 100644 --- a/Commands/RemoveStaffCommand.cs +++ b/Commands/RemoveStaffCommand.cs @@ -47,7 +47,7 @@ public class RemoveStaffCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = "User was removed from staff.\n" + Description = user.Mention + " was removed from staff by " + command.User.Mention + "." }); } catch (NotFoundException) diff --git a/Commands/RestartInterviewCommand.cs b/Commands/RestartInterviewCommand.cs index cce2c8b..4996b59 100644 --- a/Commands/RestartInterviewCommand.cs +++ b/Commands/RestartInterviewCommand.cs @@ -3,15 +3,26 @@ using System.Threading.Tasks; using DSharpPlus.Commands; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; public class RestartInterviewCommand { [Command("restartinterview")] - [Description("Restarts the automated interview in this channel, using an updated template if available.")] + [Description("Restarts the automated interview in this ticket, using an updated template if available.")] public async Task OnExecute(SlashCommandContext command) { + if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket)) + { + await command.RespondAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Red, + Description = "This channel is not a ticket." + }, true); + return; + } + await command.DeferResponseAsync(true); await Interviewer.RestartInterview(command); await command.RespondAsync(new DiscordEmbedBuilder @@ -19,5 +30,23 @@ public class RestartInterviewCommand Color = DiscordColor.Green, Description = "Interview restarted." }, true); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " restarted interview in " + command.Channel.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/SayCommand.cs b/Commands/SayCommand.cs index 0c44449..7bf8008 100644 --- a/Commands/SayCommand.cs +++ b/Commands/SayCommand.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; +using DSharpPlus.Exceptions; using DSharpPlus.Interactivity; using DSharpPlus.Interactivity.Extensions; @@ -40,6 +41,20 @@ public class SayCommand Color = DiscordColor.Cyan, Description = message.message.Replace("\\n", "\n") }); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " posted the " + message.identifier + " message in " + command.Channel.Mention + "." + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } private static async void SendMessageList(SlashCommandContext command) diff --git a/Commands/SetSummaryCommand.cs b/Commands/SetSummaryCommand.cs index 91fb474..20e5851 100644 --- a/Commands/SetSummaryCommand.cs +++ b/Commands/SetSummaryCommand.cs @@ -4,6 +4,7 @@ using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; using MySqlConnector; namespace SupportChild.Commands; @@ -17,7 +18,7 @@ public class SetSummaryCommand { ulong channelID = command.Channel.Id; // Check if ticket exists in the database - if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket _)) + if (!Database.TryGetOpenTicket(command.Channel.Id, out Database.Ticket ticket)) { await command.RespondAsync(new DiscordEmbedBuilder { @@ -41,5 +42,23 @@ public class SetSummaryCommand Color = DiscordColor.Green, Description = "Summary set." }, true); + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = command.User.Mention + " set the summary for " + command.Channel.Mention + " to:\n\n" + summary, + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } + }); + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/ToggleActiveCommand.cs b/Commands/ToggleActiveCommand.cs index 4b83323..b5848e6 100644 --- a/Commands/ToggleActiveCommand.cs +++ b/Commands/ToggleActiveCommand.cs @@ -4,6 +4,7 @@ using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; namespace SupportChild.Commands; @@ -29,11 +30,24 @@ public class ToggleActiveCommand if (Database.SetStaffActive(staffUser.Id, !staffMember.active)) { - await command.RespondAsync(new DiscordEmbedBuilder + if (user != null && user.Id != command.User.Id) { - 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." - }, true); + await command.RespondAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = staffUser.Mention + (staffMember.active ? " is now set as inactive and will no longer be randomly assigned any support tickets." + : " is now set as active and will be randomly assigned support tickets again.") + }, true); + } + else + { + await command.RespondAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = staffMember.active ? "You are now set as inactive and will no longer be randomly assigned any support tickets." + : "You are now set as active and will be randomly assigned support tickets again." + }, true); + } } else { @@ -43,5 +57,31 @@ public class ToggleActiveCommand Description = "Error: Unable to update active status in database." }, true); } + + try + { + DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); + + if (user != null && user.Id != command.User.Id) + { + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = staffUser.Mention + " set " + command.Channel.Mention + "'s status to " + (staffMember.active ? "active" : "inactive") + }); + } + else + { + await logChannel.SendMessageAsync(new DiscordEmbedBuilder + { + Color = DiscordColor.Green, + Description = staffUser.Mention + " set their own status to " + (staffMember.active ? "active" : "inactive") + }); + } + } + catch (NotFoundException) + { + Logger.Error("Could not find the log channel."); + } } } \ No newline at end of file diff --git a/Commands/TranscriptCommand.cs b/Commands/TranscriptCommand.cs index 97657c8..dbc1449 100644 --- a/Commands/TranscriptCommand.cs +++ b/Commands/TranscriptCommand.cs @@ -90,8 +90,11 @@ public class TranscriptCommand message.AddEmbed(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 } + Description = "Transcript generated by " + command.User.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }); message.AddFiles(new Dictionary { { Transcriber.GetFilename(ticket.id), file } }); diff --git a/Commands/UnassignCommand.cs b/Commands/UnassignCommand.cs index 6452696..c69c1bd 100644 --- a/Commands/UnassignCommand.cs +++ b/Commands/UnassignCommand.cs @@ -49,7 +49,11 @@ public class UnassignCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = "Staff member was unassigned from " + command.Channel.Mention + " by " + command.Member.Mention + "." + Description = "Staff member was unassigned from " + command.Channel.Mention + " by " + command.User.Mention + ".", + Footer = new DiscordEmbedBuilder.EmbedFooter + { + Text = "Ticket: " + ticket.id.ToString("00000") + } }); } catch (NotFoundException) diff --git a/Commands/UnblacklistCommand.cs b/Commands/UnblacklistCommand.cs index 06fd2ad..30cb3b4 100644 --- a/Commands/UnblacklistCommand.cs +++ b/Commands/UnblacklistCommand.cs @@ -31,7 +31,7 @@ public class UnblacklistCommand await command.RespondAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = "Removed " + user.Mention + " from blacklist." + Description = "Unblocked " + user.Mention + " from opening new tickets." }, true); try @@ -41,7 +41,7 @@ public class UnblacklistCommand await logChannel.SendMessageAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, - Description = user.Mention + " was unblacklisted from opening tickets by " + command.Member.Mention + "." + Description = user.Mention + " was unblocked from opening tickets by " + command.User.Mention + "." }); } catch (NotFoundException)