Fix logging issues
All checks were successful
Toastie-stuff/SupportChild/pipeline/head This commit looks good

This commit is contained in:
Toastie 2024-12-27 20:22:00 +13:00
parent c6579beba2
commit 66d67257be
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
4 changed files with 32 additions and 15 deletions

View file

@ -54,12 +54,23 @@ public class AddStaffCommand
cmd.ExecuteNonQuery();
cmd.Dispose();
if (alreadyStaff)
{
await command.RespondAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = alreadyStaff ? staffMember.Mention + " is already a staff member, refreshed username in database." : staffMember.Mention + " was added to staff."
Description = staffMember.Mention + " is already a staff member, refreshed username in database."
}, true);
}
else
{
await command.RespondAsync(new DiscordEmbedBuilder
{
Color = DiscordColor.Green,
Description = staffMember.Mention + " was added to staff."
}, true);
await LogChannel.Success(staffMember.Mention + " was added to staff by " + command.User.Mention + ".");
}
}
}

View file

@ -11,7 +11,6 @@ using DSharpPlus.Exceptions;
using SupportChild.Interviews;
namespace SupportChild.Commands;
public class NewCommand
{
[RequireGuild]
@ -134,6 +133,11 @@ public class NewCommand
return (false, "Error: Could not find the category to place the ticket in.");
}
if (category.Children.Count == 50)
{
return (false, "This ticket category is full, can not create ticket channel.");
}
DiscordMember member = null;
try
{
@ -152,7 +156,10 @@ public class NewCommand
{
ticketChannel = await category.Guild.CreateChannelAsync("ticket", DiscordChannelType.Text, category);
}
catch (Exception) { /* ignored */ }
catch (Exception e)
{
Logger.Error("Error occured while creating ticket.", e);
}
if (ticketChannel == null)
{
@ -174,7 +181,7 @@ public class NewCommand
catch (DiscordException e)
{
Logger.Error("Exception occurred trying to modify channel: " + e);
Logger.Error("JsomMessage: " + e.JsonMessage);
Logger.Error("JsonMessage: " + e.JsonMessage);
}
try
@ -184,7 +191,7 @@ public class NewCommand
catch (DiscordException e)
{
Logger.Error("Exception occurred trying to add channel permissions: " + e);
Logger.Error("JsomMessage: " + e.JsonMessage);
Logger.Error("JsonMessage: " + e.JsonMessage);
}
DiscordMessage message = await ticketChannel.SendMessageAsync("Hello, " + member.Mention + "!\n" + Config.welcomeMessage);
@ -231,7 +238,7 @@ public class NewCommand
catch (DiscordException e)
{
Logger.Error("Exception occurred assign random staff member: " + e);
Logger.Error("JsomMessage: " + e.JsonMessage);
Logger.Error("JsonMessage: " + e.JsonMessage);
}
}
}

View file

@ -288,7 +288,7 @@ public static class EventHandler
catch (DiscordException ex)
{
Logger.Error("Interaction Exception occurred: " + ex);
Logger.Error("JsomMessage: " + ex.JsonMessage);
Logger.Error("JsonMessage: " + ex.JsonMessage);
}
catch (Exception ex)
{

View file

@ -38,25 +38,24 @@ public static class LogChannel
try
{
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
DiscordMessageBuilder messageBuilder = new();
DiscordEmbedBuilder embedBuilder = new()
{
Color = color,
Description = message
};
if (ticketID != 0)
{
embedBuilder.WithFooter("Ticket: " + ticketID.ToString("00000"));
}
DiscordMessageBuilder messageBuilder = new();
messageBuilder.AddEmbed(embedBuilder);
if (file != null)
{
messageBuilder.AddFile(file.fileName, file.contents);
}
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
await logChannel.SendMessageAsync(messageBuilder);
}
catch (NotFoundException)