Added more detailed logging to log channel

This commit is contained in:
Toastie 2024-12-27 01:21:37 +13:00
parent b2c6478458
commit f5852dae29
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
23 changed files with 316 additions and 36 deletions

View file

@ -4,6 +4,7 @@ using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -72,5 +73,23 @@ public class AddCategoryCommand
Description = "Error: Failed adding the category to the database." Description = "Error: Failed adding the category to the database."
}, true); }, 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.");
}
} }
} }

View file

@ -18,7 +18,7 @@ public class AddCommand
[Parameter("user")][Description("User to add to ticket.")] DiscordUser user) [Parameter("user")][Description("User to add to ticket.")] DiscordUser user)
{ {
// Check if ticket exists in the database // 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 await command.RespondAsync(new DiscordEmbedBuilder
{ {
@ -62,7 +62,6 @@ public class AddCommand
Description = "Added " + member.Mention + " to ticket." Description = "Added " + member.Mention + " to ticket."
}); });
// Log it if the log channel exists
try try
{ {
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel); DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
@ -70,7 +69,11 @@ public class AddCommand
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = member.Mention + " was added to " + command.Channel.Mention + 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) catch (NotFoundException)

View file

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using DSharpPlus.Commands; using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -52,5 +53,23 @@ public class AddMessageCommand
Description = "Error: Failed adding the message to the database." Description = "Error: Failed adding the message to the database."
}, true); }, 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.");
}
} }
} }

View file

@ -65,7 +65,7 @@ public class AddStaffCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = staffMember.Mention + " was added to staff.\n" Description = staffMember.Mention + " was added to staff by " + command.User.Mention + "."
}); });
} }
catch (NotFoundException) catch (NotFoundException)

View file

@ -115,11 +115,10 @@ public class AdminCommands
DiscordUser ticketUser = (user == null ? command.User : user); DiscordUser ticketUser = (user == null ? command.User : user);
long id = Database.NewTicket(ticketUser.Id, 0, command.Channel.Id); long id = Database.NewTicket(ticketUser.Id, 0, command.Channel.Id);
string ticketID = id.ToString("00000");
await command.RespondAsync(new DiscordEmbedBuilder await command.RespondAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Channel has been designated ticket " + ticketID + "." Description = "Channel has been designated ticket " + id.ToString("00000") + "."
}); });
try try
@ -129,7 +128,11 @@ public class AdminCommands
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, 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) catch (NotFoundException)
@ -189,7 +192,11 @@ public class AdminCommands
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, 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) catch (NotFoundException)
@ -217,6 +224,21 @@ public class AdminCommands
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Reloading bot application..." 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..."); Logger.Log("Reloading bot...");
await SupportChild.Reload(); await SupportChild.Reload();
} }
@ -328,9 +350,22 @@ public class AdminCommands
await command.RespondAsync(new DiscordEmbedBuilder await command.RespondAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Uploaded interview template." Description = "Uploaded interview template."
}, true); }, 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.");
}
} }
} }

View file

@ -99,7 +99,11 @@ public class AssignCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, 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) catch (NotFoundException)

View file

@ -32,7 +32,7 @@ public class BlacklistCommand
await command.RespondAsync(new DiscordEmbedBuilder await command.RespondAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Blacklisted " + user.Mention + "." Description = "Blocked " + user.Mention + " from opening new tickets."
}, true); }, true);
try try
@ -42,7 +42,7 @@ public class BlacklistCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, 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) catch (NotFoundException)

View file

@ -92,7 +92,10 @@ public class CloseCommand
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket " + ticket.id.ToString("00000") + " closed by " + Description = "Ticket " + ticket.id.ToString("00000") + " closed by " +
interaction.User.Mention + ".\n" + closeReason, 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); await using FileStream file = new FileStream(Transcriber.GetPath(ticket.id), FileMode.Open, FileAccess.Read);
@ -114,7 +117,10 @@ public class CloseCommand
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket " + ticket.id.ToString("00000") + " which you opened has now been closed, " + Description = "Ticket " + ticket.id.ToString("00000") + " which you opened has now been closed, " +
"check the transcript for more info.\n" + closeReason, "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 try

View file

@ -6,6 +6,7 @@ using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -49,5 +50,19 @@ public class CreateButtonPanelCommand
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Successfully created message, make sure to run this command again if you add new categories to the bot." Description = "Successfully created message, make sure to run this command again if you add new categories to the bot."
}, true); }, 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.");
}
} }
} }

View file

@ -6,6 +6,7 @@ using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -27,6 +28,20 @@ public class CreateSelectionBoxPanelCommand
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Successfully created message, make sure to run this command again if you add new categories to the bot." Description = "Successfully created message, make sure to run this command again if you add new categories to the bot."
}, true); }, 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<List<DiscordSelectComponent>> GetSelectComponents(SlashCommandContext command, string placeholder) public static async Task<List<DiscordSelectComponent>> GetSelectComponents(SlashCommandContext command, string placeholder)

View file

@ -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) [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 // 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 await command.RespondAsync(new DiscordEmbedBuilder
{ {
@ -83,5 +83,23 @@ public class MoveCommand
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket was moved to `" + categoryChannel.Name + "`." 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.");
}
} }
} }

View file

@ -166,11 +166,9 @@ public class NewCommand
} }
long id = Database.NewTicket(member.Id, staffID, ticketChannel.Id); long id = Database.NewTicket(member.Id, staffID, ticketChannel.Id);
string ticketID = id.ToString("00000");
try try
{ {
await ticketChannel.ModifyAsync(modifiedAttributes => modifiedAttributes.Name = "ticket-" + ticketID); await ticketChannel.ModifyAsync(modifiedAttributes => modifiedAttributes.Name = "ticket-" + id.ToString("00000"));
} }
catch (DiscordException e) catch (DiscordException e)
{ {
@ -245,8 +243,11 @@ public class NewCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".\n", Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".",
Footer = new DiscordEmbedBuilder.EmbedFooter { Text = "Ticket " + ticketID } Footer = new DiscordEmbedBuilder.EmbedFooter
{
Text = "Ticket: " + id.ToString("00000")
}
}); });
} }
catch (NotFoundException) catch (NotFoundException)

View file

@ -76,7 +76,11 @@ public class RandomAssignCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, 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) catch (NotFoundException)

View file

@ -4,6 +4,7 @@ using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -13,9 +14,9 @@ public class RemoveCategoryCommand
[Command("removecategory")] [Command("removecategory")]
[Description("Removes the ability for users to open tickets in a specific category.")] [Description("Removes the ability for users to open tickets in a specific category.")]
public async Task OnExecute(SlashCommandContext command, 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 await command.RespondAsync(new DiscordEmbedBuilder
{ {
@ -25,7 +26,7 @@ public class RemoveCategoryCommand
return; return;
} }
if (Database.RemoveCategory(channel.Id)) if (Database.RemoveCategory(category.Id))
{ {
await command.RespondAsync(new DiscordEmbedBuilder await command.RespondAsync(new DiscordEmbedBuilder
{ {
@ -41,5 +42,20 @@ public class RemoveCategoryCommand
Description = "Error: Failed removing the category from the database." Description = "Error: Failed removing the category from the database."
}, true); }, 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.");
}
} }
} }

View file

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using DSharpPlus.Commands; using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -41,5 +42,19 @@ public class RemoveMessageCommand
Description = "Error: Failed removing the message from the database." Description = "Error: Failed removing the message from the database."
}, true); }, 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.");
}
} }
} }

View file

@ -47,7 +47,7 @@ public class RemoveStaffCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "User was removed from staff.\n" Description = user.Mention + " was removed from staff by " + command.User.Mention + "."
}); });
} }
catch (NotFoundException) catch (NotFoundException)

View file

@ -3,15 +3,26 @@ using System.Threading.Tasks;
using DSharpPlus.Commands; using DSharpPlus.Commands;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
public class RestartInterviewCommand public class RestartInterviewCommand
{ {
[Command("restartinterview")] [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) 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 command.DeferResponseAsync(true);
await Interviewer.RestartInterview(command); await Interviewer.RestartInterview(command);
await command.RespondAsync(new DiscordEmbedBuilder await command.RespondAsync(new DiscordEmbedBuilder
@ -19,5 +30,23 @@ public class RestartInterviewCommand
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Interview restarted." Description = "Interview restarted."
}, true); }, 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.");
}
} }
} }

View file

@ -5,6 +5,7 @@ using System.Threading.Tasks;
using DSharpPlus.Commands; using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Exceptions;
using DSharpPlus.Interactivity; using DSharpPlus.Interactivity;
using DSharpPlus.Interactivity.Extensions; using DSharpPlus.Interactivity.Extensions;
@ -40,6 +41,20 @@ public class SayCommand
Color = DiscordColor.Cyan, Color = DiscordColor.Cyan,
Description = message.message.Replace("\\n", "\n") 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) private static async void SendMessageList(SlashCommandContext command)

View file

@ -4,6 +4,7 @@ using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
using MySqlConnector; using MySqlConnector;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -17,7 +18,7 @@ public class SetSummaryCommand
{ {
ulong channelID = command.Channel.Id; ulong channelID = command.Channel.Id;
// Check if ticket exists in the database // 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 await command.RespondAsync(new DiscordEmbedBuilder
{ {
@ -41,5 +42,23 @@ public class SetSummaryCommand
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Summary set." Description = "Summary set."
}, true); }, 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.");
}
} }
} }

View file

@ -4,6 +4,7 @@ using DSharpPlus.Commands;
using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.ContextChecks;
using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities; using DSharpPlus.Entities;
using DSharpPlus.Exceptions;
namespace SupportChild.Commands; namespace SupportChild.Commands;
@ -29,11 +30,24 @@ public class ToggleActiveCommand
if (Database.SetStaffActive(staffUser.Id, !staffMember.active)) if (Database.SetStaffActive(staffUser.Id, !staffMember.active))
{ {
await command.RespondAsync(new DiscordEmbedBuilder if (user != null && user.Id != command.User.Id)
{ {
Color = DiscordColor.Green, await command.RespondAsync(new DiscordEmbedBuilder
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); 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 else
{ {
@ -43,5 +57,31 @@ public class ToggleActiveCommand
Description = "Error: Unable to update active status in database." Description = "Error: Unable to update active status in database."
}, true); }, 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.");
}
} }
} }

View file

@ -90,8 +90,11 @@ public class TranscriptCommand
message.AddEmbed(new DiscordEmbedBuilder message.AddEmbed(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Ticket " + ticket.id.ToString("00000") + " transcript generated by " + command.Member.Mention + ".\n", Description = "Transcript generated by " + command.User.Mention + ".",
Footer = new DiscordEmbedBuilder.EmbedFooter { Text = '#' + command.Channel.Name } Footer = new DiscordEmbedBuilder.EmbedFooter
{
Text = "Ticket: " + ticket.id.ToString("00000")
}
}); });
message.AddFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } }); message.AddFiles(new Dictionary<string, Stream> { { Transcriber.GetFilename(ticket.id), file } });

View file

@ -49,7 +49,11 @@ public class UnassignCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, 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) catch (NotFoundException)

View file

@ -31,7 +31,7 @@ public class UnblacklistCommand
await command.RespondAsync(new DiscordEmbedBuilder await command.RespondAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, Color = DiscordColor.Green,
Description = "Removed " + user.Mention + " from blacklist." Description = "Unblocked " + user.Mention + " from opening new tickets."
}, true); }, true);
try try
@ -41,7 +41,7 @@ public class UnblacklistCommand
await logChannel.SendMessageAsync(new DiscordEmbedBuilder await logChannel.SendMessageAsync(new DiscordEmbedBuilder
{ {
Color = DiscordColor.Green, 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) catch (NotFoundException)