Fix logging issues
All checks were successful
Toastie-stuff/SupportChild/pipeline/head This commit looks good
All checks were successful
Toastie-stuff/SupportChild/pipeline/head This commit looks good
This commit is contained in:
parent
c6579beba2
commit
66d67257be
4 changed files with 32 additions and 15 deletions
|
@ -54,12 +54,23 @@ public class AddStaffCommand
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Dispose();
|
cmd.Dispose();
|
||||||
|
|
||||||
|
if (alreadyStaff)
|
||||||
|
{
|
||||||
await command.RespondAsync(new DiscordEmbedBuilder
|
await command.RespondAsync(new DiscordEmbedBuilder
|
||||||
{
|
{
|
||||||
Color = DiscordColor.Green,
|
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);
|
}, true);
|
||||||
|
|
||||||
await LogChannel.Success(staffMember.Mention + " was added to staff by " + command.User.Mention + ".");
|
await LogChannel.Success(staffMember.Mention + " was added to staff by " + command.User.Mention + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -11,7 +11,6 @@ using DSharpPlus.Exceptions;
|
||||||
using SupportChild.Interviews;
|
using SupportChild.Interviews;
|
||||||
|
|
||||||
namespace SupportChild.Commands;
|
namespace SupportChild.Commands;
|
||||||
|
|
||||||
public class NewCommand
|
public class NewCommand
|
||||||
{
|
{
|
||||||
[RequireGuild]
|
[RequireGuild]
|
||||||
|
@ -134,6 +133,11 @@ public class NewCommand
|
||||||
return (false, "Error: Could not find the category to place the ticket in.");
|
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;
|
DiscordMember member = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -152,7 +156,10 @@ public class NewCommand
|
||||||
{
|
{
|
||||||
ticketChannel = await category.Guild.CreateChannelAsync("ticket", DiscordChannelType.Text, category);
|
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)
|
if (ticketChannel == null)
|
||||||
{
|
{
|
||||||
|
@ -174,7 +181,7 @@ public class NewCommand
|
||||||
catch (DiscordException e)
|
catch (DiscordException e)
|
||||||
{
|
{
|
||||||
Logger.Error("Exception occurred trying to modify channel: " + e);
|
Logger.Error("Exception occurred trying to modify channel: " + e);
|
||||||
Logger.Error("JsomMessage: " + e.JsonMessage);
|
Logger.Error("JsonMessage: " + e.JsonMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -184,7 +191,7 @@ public class NewCommand
|
||||||
catch (DiscordException e)
|
catch (DiscordException e)
|
||||||
{
|
{
|
||||||
Logger.Error("Exception occurred trying to add channel permissions: " + 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);
|
DiscordMessage message = await ticketChannel.SendMessageAsync("Hello, " + member.Mention + "!\n" + Config.welcomeMessage);
|
||||||
|
@ -231,7 +238,7 @@ public class NewCommand
|
||||||
catch (DiscordException e)
|
catch (DiscordException e)
|
||||||
{
|
{
|
||||||
Logger.Error("Exception occurred assign random staff member: " + e);
|
Logger.Error("Exception occurred assign random staff member: " + e);
|
||||||
Logger.Error("JsomMessage: " + e.JsonMessage);
|
Logger.Error("JsonMessage: " + e.JsonMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,7 +288,7 @@ public static class EventHandler
|
||||||
catch (DiscordException ex)
|
catch (DiscordException ex)
|
||||||
{
|
{
|
||||||
Logger.Error("Interaction Exception occurred: " + ex);
|
Logger.Error("Interaction Exception occurred: " + ex);
|
||||||
Logger.Error("JsomMessage: " + ex.JsonMessage);
|
Logger.Error("JsonMessage: " + ex.JsonMessage);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,25 +38,24 @@ public static class LogChannel
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
|
|
||||||
DiscordMessageBuilder messageBuilder = new();
|
|
||||||
DiscordEmbedBuilder embedBuilder = new()
|
DiscordEmbedBuilder embedBuilder = new()
|
||||||
{
|
{
|
||||||
Color = color,
|
Color = color,
|
||||||
Description = message
|
Description = message
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ticketID != 0)
|
if (ticketID != 0)
|
||||||
{
|
{
|
||||||
embedBuilder.WithFooter("Ticket: " + ticketID.ToString("00000"));
|
embedBuilder.WithFooter("Ticket: " + ticketID.ToString("00000"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiscordMessageBuilder messageBuilder = new();
|
||||||
|
messageBuilder.AddEmbed(embedBuilder);
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
messageBuilder.AddFile(file.fileName, file.contents);
|
messageBuilder.AddFile(file.fileName, file.contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
||||||
await logChannel.SendMessageAsync(messageBuilder);
|
await logChannel.SendMessageAsync(messageBuilder);
|
||||||
}
|
}
|
||||||
catch (NotFoundException)
|
catch (NotFoundException)
|
||||||
|
|
Loading…
Reference in a new issue