Refactored log channel handling
This commit is contained in:
parent
dac221246c
commit
c6579beba2
27 changed files with 171 additions and 522 deletions
|
@ -74,22 +74,6 @@ public class AddCategoryCommand
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " added `" + category.Name + "` as `" + title + "` to the category list.");
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -62,24 +62,7 @@ public class AddCommand
|
||||||
Description = "Added " + member.Mention + " to ticket."
|
Description = "Added " + member.Mention + " to ticket."
|
||||||
});
|
});
|
||||||
|
|
||||||
try
|
await LogChannel.Success(member.Mention + " was added to " + command.Channel.Mention + " by " + command.User.Mention + ".", ticket.id);
|
||||||
{
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = member.Mention + " was added to " + command.Channel.Mention +
|
|
||||||
" by " + command.User.Mention + ".",
|
|
||||||
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
||||||
{
|
|
||||||
Text = "Ticket: " + ticket.id.ToString("00000")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using DSharpPlus.Entities;
|
using DSharpPlus.Entities;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DSharpPlus.Commands;
|
using DSharpPlus.Commands;
|
||||||
|
@ -27,7 +28,7 @@ public class AddMessageCommand
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Database.TryGetMessage(identifier.ToLower(), out Database.Message _))
|
if (Database.TryGetMessage(identifier.ToLower(CultureInfo.InvariantCulture), out Database.Message _))
|
||||||
{
|
{
|
||||||
await command.RespondAsync(new DiscordEmbedBuilder
|
await command.RespondAsync(new DiscordEmbedBuilder
|
||||||
{
|
{
|
||||||
|
@ -54,22 +55,6 @@ public class AddMessageCommand
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " added or updated `" + identifier + "` in the /say command.\n\nContent:\n\n" + message);
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,19 +60,6 @@ public class AddStaffCommand
|
||||||
Description = alreadyStaff ? staffMember.Mention + " is already a staff member, refreshed username in database." : staffMember.Mention + " was added to staff."
|
Description = alreadyStaff ? staffMember.Mention + " is already a staff member, refreshed username in database." : staffMember.Mention + " was added to staff."
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try
|
await LogChannel.Success(staffMember.Mention + " was added to staff by " + command.User.Mention + ".");
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = staffMember.Mention + " was added to staff by " + command.User.Mention + "."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -40,24 +40,7 @@ public class AdminCommands
|
||||||
Description = "Channel has been designated ticket " + id.ToString("00000") + "."
|
Description = "Channel has been designated ticket " + id.ToString("00000") + "."
|
||||||
});
|
});
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.Channel.Mention + " has been designated ticket " + id.ToString("00000") + " by " + command.Member?.Mention + ".", (uint)id);
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[RequireGuild]
|
[RequireGuild]
|
||||||
|
@ -121,24 +104,7 @@ public class AdminCommands
|
||||||
Description = "Channel has been undesignated as a ticket."
|
Description = "Channel has been undesignated as a ticket."
|
||||||
});
|
});
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.Channel.Mention + " has been undesignated as a ticket by " + command.User.Mention + ".", ticket.id);
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -161,19 +127,7 @@ public class AdminCommands
|
||||||
Description = "Reloading bot application..."
|
Description = "Reloading bot application..."
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.Channel.Mention + " reloaded the bot.");
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Log("Reloading bot...");
|
Logger.Log("Reloading bot...");
|
||||||
await SupportChild.Reload();
|
await SupportChild.Reload();
|
||||||
|
|
|
@ -89,26 +89,9 @@ public class AssignCommand
|
||||||
Description = "You have been assigned to a support ticket: " + command.Channel.Mention
|
Description = "You have been assigned to a support ticket: " + command.Channel.Mention
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (UnauthorizedException) { }
|
catch (UnauthorizedException) { /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success(member.Mention + " was assigned to " + command.Channel.Mention + " by " + command.User.Mention + ".", ticket.id);
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,20 +35,7 @@ public class BlacklistCommand
|
||||||
Description = "Blocked " + user.Mention + " from opening new tickets."
|
Description = "Blocked " + user.Mention + " from opening new tickets."
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try
|
await LogChannel.Success(user.Mention + " was blocked from opening tickets by " + command.User.Mention + ".");
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = user.Mention + " was blocked from opening tickets by " + command.User.Mention + "."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,28 +141,12 @@ public class CloseCommand
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
|
|
||||||
await using FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
await using FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||||
DiscordMessageBuilder message = new DiscordMessageBuilder();
|
await LogChannel.Success("Ticket " + ticket.id.ToString("00000") + " closed by " + interaction.User.Mention + ".\n" + closeReason, ticket.id, new Utilities.File(fileName, file));
|
||||||
message.AddEmbed(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = "Ticket " + ticket.id.ToString("00000") + " closed by " +
|
|
||||||
interaction.User.Mention + ".\n" + closeReason,
|
|
||||||
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
||||||
{
|
|
||||||
Text = "Ticket: " + ticket.id.ToString("00000")
|
|
||||||
}
|
}
|
||||||
});
|
catch (Exception e)
|
||||||
message.AddFiles(new Dictionary<string, Stream> { { fileName, file } });
|
|
||||||
|
|
||||||
await logChannel.SendMessageAsync(message);
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
{
|
||||||
Logger.Error("Could not send message in log channel.");
|
Logger.Error("Error occurred sending transcript log message. ", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.closingNotifications)
|
if (Config.closingNotifications)
|
||||||
|
@ -200,13 +184,12 @@ public class CloseCommand
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
message.AddFiles(new Dictionary<string, Stream> { { fileName, file } });
|
message.AddFiles(new Dictionary<string, Stream> { { fileName, file } });
|
||||||
|
|
||||||
await staffMember.SendMessageAsync(message);
|
await staffMember.SendMessageAsync(message);
|
||||||
}
|
}
|
||||||
catch (NotFoundException) { }
|
catch (NotFoundException) { /* ignore */ }
|
||||||
catch (UnauthorizedException) { }
|
catch (UnauthorizedException) { /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
Database.ArchiveTicket(ticket);
|
Database.ArchiveTicket(ticket);
|
||||||
|
|
|
@ -51,18 +51,6 @@ public class CreateButtonPanelCommand
|
||||||
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
|
await LogChannel.Success(command.User.Mention + " created a new button panel in " + command.Channel.Mention + ".");
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -29,19 +29,7 @@ public class CreateSelectionBoxPanelCommand
|
||||||
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
|
await LogChannel.Success(command.User.Mention + " created a new selector panel in " + command.Channel.Mention + ".");
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<List<DiscordSelectComponent>> GetSelectComponents(SlashCommandContext command, string placeholder)
|
public static async Task<List<DiscordSelectComponent>> GetSelectComponents(SlashCommandContext command, string placeholder)
|
||||||
|
|
|
@ -45,23 +45,7 @@ public class InterviewCommands
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " restarted interview in " + command.Channel.Mention + ".", ticket.id);
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("stop")]
|
[Command("stop")]
|
||||||
|
@ -107,22 +91,6 @@ public class InterviewCommands
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " stopped the interview in " + command.Channel.Mention + ".", ticket.id);
|
||||||
{
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = command.User.Mention + " stopped the interview in " + command.Channel.Mention + ".",
|
|
||||||
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
||||||
{
|
|
||||||
Text = "Ticket: " + ticket.id.ToString("00000")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -168,18 +168,12 @@ public class InterviewTemplateCommands
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
MemoryStream memStream = new(Encoding.UTF8.GetBytes(Database.GetInterviewTemplateJSON(template.categoryID)));
|
MemoryStream memStream = new(Encoding.UTF8.GetBytes(Database.GetInterviewTemplateJSON(template.categoryID)));
|
||||||
|
await LogChannel.Success(command.User.Mention + " uploaded a new interview template for the `" + category.Name + "` category.", 0,
|
||||||
// Log it if the log channel exists
|
new Utilities.File("interview-template-" + template.categoryID + ".json", memStream));
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordMessageBuilder().AddEmbed(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = command.User.Mention + " uploaded a new interview template for the `" + category.Name + "` category."
|
|
||||||
}).AddFile("interview-template-" + template.categoryID + ".json", memStream));
|
|
||||||
}
|
}
|
||||||
catch (NotFoundException)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error("Could not send message in log channel.");
|
Logger.Error("Unable to log interview template upload.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@ -241,19 +235,7 @@ public class InterviewTemplateCommands
|
||||||
Description = "Deleted interview template."
|
Description = "Deleted interview template."
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " deleted the interview template for the `" + category.Name + "` category.", 0,
|
||||||
{
|
new Utilities.File("interview-template-" + category.Id + ".json", memStream));
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordMessageBuilder().AddEmbed(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = command.User.Mention + " deleted the interview template for the `" + category.Name + "` category."
|
|
||||||
}).AddFile("interview-template-" + category.Id + ".json", memStream));
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -105,22 +105,6 @@ public class MoveCommand
|
||||||
Description = "Ticket was moved to `" + categoryChannel.Name + "`."
|
Description = "Ticket was moved to `" + categoryChannel.Name + "`."
|
||||||
});
|
});
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " moved " + command.Channel.Mention + " to `" + categoryChannel.Name + "`.", ticket.id);
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -236,25 +236,7 @@ public class NewCommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success("Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".", (uint)id);
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = "Ticket " + ticketChannel.Mention + " opened by " + member.Mention + ".",
|
|
||||||
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
||||||
{
|
|
||||||
Text = "Ticket: " + id.ToString("00000")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return (true, "Ticket opened, " + member.Mention + "!\n" + ticketChannel.Mention);
|
return (true, "Ticket opened, " + member.Mention + "!\n" + ticketChannel.Mention);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -74,24 +74,7 @@ public class RandomAssignCommand
|
||||||
catch (UnauthorizedException) { /* ignore */ }
|
catch (UnauthorizedException) { /* ignore */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success(staffMember.Mention + " was randomly assigned to " + command.Channel.Mention + " by " + command.User.Mention + ".", ticket.id);
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static async Task<DiscordMember> GetRandomVerifiedStaffMember(DiscordChannel channel, ulong creatorID, ulong currentStaffID, DiscordRole targetRole)
|
internal static async Task<DiscordMember> GetRandomVerifiedStaffMember(DiscordChannel channel, ulong creatorID, ulong currentStaffID, DiscordRole targetRole)
|
||||||
|
|
|
@ -43,19 +43,6 @@ public class RemoveCategoryCommand
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success("`" + category.Name + "` was removed by " + command.User.Mention + ".");
|
||||||
{
|
|
||||||
// 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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using DSharpPlus.Entities;
|
using DSharpPlus.Entities;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DSharpPlus.Commands;
|
using DSharpPlus.Commands;
|
||||||
|
@ -16,7 +17,7 @@ public class RemoveMessageCommand
|
||||||
public async Task OnExecute(SlashCommandContext command,
|
public async Task OnExecute(SlashCommandContext command,
|
||||||
[Parameter("identifier")][Description("The identifier word used in the /say command.")] string identifier)
|
[Parameter("identifier")][Description("The identifier word used in the /say command.")] string identifier)
|
||||||
{
|
{
|
||||||
if (!Database.TryGetMessage(identifier.ToLower(), out Database.Message _))
|
if (!Database.TryGetMessage(identifier.ToLower(CultureInfo.InvariantCulture), out Database.Message _))
|
||||||
{
|
{
|
||||||
await command.RespondAsync(new DiscordEmbedBuilder
|
await command.RespondAsync(new DiscordEmbedBuilder
|
||||||
{
|
{
|
||||||
|
@ -43,18 +44,6 @@ public class RemoveMessageCommand
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success("`" + identifier + "` was removed from the /say command by " + command.User.Mention + ".");
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,6 @@ 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;
|
||||||
|
@ -50,24 +49,7 @@ public class RemoveStaffCommand
|
||||||
Logger.Error("Error when trying to send message about unassigning staff member from ticket-" + assignedTicket.id.ToString("00000"), e);
|
Logger.Error("Error when trying to send message about unassigning staff member from ticket-" + assignedTicket.id.ToString("00000"), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
await LogChannel.Success("<@" + assignedTicket.assignedStaffID + "> was unassigned from <#" + assignedTicket.channelID + "> by " + command.User.Mention + ".", assignedTicket.id);
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = "<@" + assignedTicket.assignedStaffID + "> was unassigned from <#" + assignedTicket.channelID + "> by " + command.User.Mention + ".",
|
|
||||||
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
||||||
{
|
|
||||||
Text = "Ticket: " + assignedTicket.id.ToString("00000")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,19 +66,6 @@ public class RemoveStaffCommand
|
||||||
Description = "User was removed from staff."
|
Description = "User was removed from staff."
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try
|
await LogChannel.Success(user.Mention + " was removed from staff by " + command.User.Mention + ".");
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = user.Mention + " was removed from staff by " + command.User.Mention + "."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using DSharpPlus.Entities;
|
using DSharpPlus.Entities;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using DSharpPlus.Commands;
|
using DSharpPlus.Commands;
|
||||||
using DSharpPlus.Commands.ContextChecks;
|
using DSharpPlus.Commands.ContextChecks;
|
||||||
|
@ -22,11 +23,12 @@ public class SayCommand
|
||||||
// Print list of all messages if no identifier is provided
|
// Print list of all messages if no identifier is provided
|
||||||
if (identifier == null)
|
if (identifier == null)
|
||||||
{
|
{
|
||||||
SendMessageList(command);
|
await SendMessageList(command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Database.TryGetMessage(identifier.ToLower(), out Database.Message message))
|
if (!Database.TryGetMessage(identifier.ToLower(CultureInfo.InvariantCulture),
|
||||||
|
out Database.Message message))
|
||||||
{
|
{
|
||||||
await command.RespondAsync(new DiscordEmbedBuilder
|
await command.RespondAsync(new DiscordEmbedBuilder
|
||||||
{
|
{
|
||||||
|
@ -42,22 +44,10 @@ public class SayCommand
|
||||||
Description = message.message.Replace("\\n", "\n")
|
Description = message.message.Replace("\\n", "\n")
|
||||||
});
|
});
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " posted the " + message.identifier + " message in " + command.Channel.Mention + ".");
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async void SendMessageList(SlashCommandContext command)
|
private static async Task SendMessageList(SlashCommandContext command)
|
||||||
{
|
{
|
||||||
List<Database.Message> messages = Database.GetAllMessages();
|
List<Database.Message> messages = Database.GetAllMessages();
|
||||||
if (messages.Count == 0)
|
if (messages.Count == 0)
|
||||||
|
|
|
@ -43,22 +43,6 @@ public class SetSummaryCommand
|
||||||
Description = "Summary set."
|
Description = "Summary set."
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try
|
await LogChannel.Success(command.User.Mention + " set the summary for " + command.Channel.Mention + " to:\n\n" + summary, ticket.id);
|
||||||
{
|
|
||||||
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 send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,30 +58,13 @@ public class ToggleActiveCommand
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
|
|
||||||
if (user != null && user.Id != command.User.Id)
|
if (user != null && user.Id != command.User.Id)
|
||||||
{
|
{
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
await LogChannel.Success(staffUser.Mention + " set " + command.Channel.Mention + "'s status to " + (staffMember.active ? "active" : "inactive"));
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = staffUser.Mention + " set " + command.Channel.Mention + "'s status to " + (staffMember.active ? "active" : "inactive")
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
await LogChannel.Success(staffUser.Mention + " set their own status to " + (staffMember.active ? "active" : "inactive"));
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = staffUser.Mention + " set their own status to " + (staffMember.active ? "active" : "inactive")
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -121,27 +121,12 @@ public class TranscriptCommand
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await using FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
await using FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read);
|
||||||
|
await LogChannel.Success("Transcript generated by " + command.User.Mention + ".", ticket.id, new Utilities.File(fileName, file));
|
||||||
DiscordMessageBuilder message = new DiscordMessageBuilder();
|
|
||||||
message.AddEmbed(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = "Transcript generated by " + command.User.Mention + ".",
|
|
||||||
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
||||||
{
|
|
||||||
Text = "Ticket: " + ticket.id.ToString("00000")
|
|
||||||
}
|
}
|
||||||
});
|
catch (Exception e)
|
||||||
message.AddFiles(new Dictionary<string, Stream> { { fileName, file } });
|
|
||||||
|
|
||||||
await logChannel.SendMessageAsync(message);
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
{
|
||||||
Logger.Error("Could not send message in log channel.");
|
Logger.Error("Failed to log transcript generation.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await SendDirectMessage(command, fileName, filePath, zipSize, ticket.id))
|
if (await SendDirectMessage(command, fileName, filePath, zipSize, ticket.id))
|
||||||
|
|
|
@ -42,23 +42,6 @@ public class UnassignCommand
|
||||||
Description = "Unassigned <@" + ticket.assignedStaffID + "> from ticket."
|
Description = "Unassigned <@" + ticket.assignedStaffID + "> from ticket."
|
||||||
});
|
});
|
||||||
|
|
||||||
try
|
await LogChannel.Success("<@" + ticket.assignedStaffID + "> was unassigned from <#" + ticket.channelID + "> by " + command.User.Mention + ".", ticket.id);
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = "<@" + ticket.assignedStaffID + "> was unassigned from <#" + ticket.channelID + "> by " + command.User.Mention + ".",
|
|
||||||
Footer = new DiscordEmbedBuilder.EmbedFooter
|
|
||||||
{
|
|
||||||
Text = "Ticket: " + ticket.id.ToString("00000")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,20 +34,7 @@ public class UnblacklistCommand
|
||||||
Description = "Unblocked " + user.Mention + " from opening new tickets."
|
Description = "Unblocked " + user.Mention + " from opening new tickets."
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
try
|
await LogChannel.Success(user.Mention + " was unblocked from opening tickets by " + command.User.Mention + ".");
|
||||||
{
|
|
||||||
// Log it if the log channel exists
|
|
||||||
DiscordChannel logChannel = await SupportChild.client.GetChannelAsync(Config.logChannel);
|
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
|
||||||
{
|
|
||||||
Color = DiscordColor.Green,
|
|
||||||
Description = user.Mention + " was unblocked from opening tickets by " + command.User.Mention + "."
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (NotFoundException)
|
|
||||||
{
|
|
||||||
Logger.Error("Could not send message in log channel.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,8 +112,8 @@ public static class EventHandler
|
||||||
Description = "A ticket you are assigned to has been updated: " + e.Channel.Mention
|
Description = "A ticket you are assigned to has been updated: " + e.Channel.Mention
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (NotFoundException) { }
|
catch (NotFoundException) { /* ignored */ }
|
||||||
catch (UnauthorizedException) { }
|
catch (UnauthorizedException) { /* ignored */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,10 +174,7 @@ public static class EventHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Database.TryGetAssignedTickets(e.Member.Id, out List<Database.Ticket> assignedTickets) && Config.logChannel != 0)
|
if (LogChannel.IsEnabled && Database.TryGetAssignedTickets(e.Member.Id, out List<Database.Ticket> assignedTickets))
|
||||||
{
|
|
||||||
DiscordChannel logChannel = await client.GetChannelAsync(Config.logChannel);
|
|
||||||
if (logChannel != null)
|
|
||||||
{
|
{
|
||||||
foreach (Database.Ticket ticket in assignedTickets)
|
foreach (Database.Ticket ticket in assignedTickets)
|
||||||
{
|
{
|
||||||
|
@ -186,18 +183,13 @@ public static class EventHandler
|
||||||
DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
|
DiscordChannel channel = await client.GetChannelAsync(ticket.channelID);
|
||||||
if (channel?.GuildId == e.Guild.Id)
|
if (channel?.GuildId == e.Guild.Id)
|
||||||
{
|
{
|
||||||
await logChannel.SendMessageAsync(new DiscordEmbedBuilder
|
await LogChannel.Warn("Assigned staff member '" + e.Member.Username + "#" + e.Member.Discriminator + "' has left the server: <#" + channel.Id + ">");
|
||||||
{
|
|
||||||
Color = DiscordColor.Red,
|
|
||||||
Description = "Assigned staff member '" + e.Member.Username + "#" + e.Member.Discriminator + "' has left the server: <#" + channel.Id + ">"
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) { /* ignored */ }
|
catch (Exception) { /* ignored */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static async Task OnComponentInteractionCreated(DiscordClient client, ComponentInteractionCreatedEventArgs e)
|
public static async Task OnComponentInteractionCreated(DiscordClient client, ComponentInteractionCreatedEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -253,45 +245,41 @@ public static class EventHandler
|
||||||
Logger.Warn("Unknown form input received! '" + e.Id + "'");
|
Logger.Warn("Unknown form input received! '" + e.Id + "'");
|
||||||
return;
|
return;
|
||||||
case DiscordComponentType.UserSelect:
|
case DiscordComponentType.UserSelect:
|
||||||
switch (e.Id)
|
if (e.Id.StartsWith("supportchild_interviewuserselector"))
|
||||||
{
|
{
|
||||||
case not null when e.Id.StartsWith("supportchild_interviewuserselector"):
|
|
||||||
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
||||||
return;
|
return;
|
||||||
default:
|
}
|
||||||
|
|
||||||
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
case DiscordComponentType.RoleSelect:
|
case DiscordComponentType.RoleSelect:
|
||||||
switch (e.Id)
|
if (e.Id.StartsWith("supportchild_interviewroleselector"))
|
||||||
{
|
{
|
||||||
case not null when e.Id.StartsWith("supportchild_interviewroleselector"):
|
|
||||||
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
||||||
return;
|
return;
|
||||||
default:
|
}
|
||||||
|
|
||||||
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
case DiscordComponentType.MentionableSelect:
|
case DiscordComponentType.MentionableSelect:
|
||||||
switch (e.Id)
|
if (e.Id.StartsWith("supportchild_interviewmentionableselector"))
|
||||||
{
|
{
|
||||||
case not null when e.Id.StartsWith("supportchild_interviewmentionableselector"):
|
|
||||||
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
||||||
return;
|
return;
|
||||||
default:
|
}
|
||||||
|
|
||||||
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
case DiscordComponentType.ChannelSelect:
|
case DiscordComponentType.ChannelSelect:
|
||||||
switch (e.Id)
|
if (e.Id.StartsWith("supportchild_interviewchannelselector"))
|
||||||
{
|
{
|
||||||
case not null when e.Id.StartsWith("supportchild_interviewchannelselector"):
|
|
||||||
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
await Interviewer.ProcessButtonOrSelectorResponse(e.Interaction);
|
||||||
return;
|
return;
|
||||||
default:
|
}
|
||||||
|
|
||||||
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
Logger.Warn("Unknown selection box option received! '" + e.Id + "'");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
Logger.Warn("Unknown interaction type received! '" + e.Interaction.Data.ComponentType + "'");
|
Logger.Warn("Unknown interaction type received! '" + e.Interaction.Data.ComponentType + "'");
|
||||||
break;
|
break;
|
||||||
|
|
75
LogChannel.cs
Normal file
75
LogChannel.cs
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DSharpPlus.Entities;
|
||||||
|
using DSharpPlus.Exceptions;
|
||||||
|
|
||||||
|
namespace SupportChild;
|
||||||
|
|
||||||
|
public static class LogChannel
|
||||||
|
{
|
||||||
|
public static bool IsEnabled => Config.logChannel != 0;
|
||||||
|
|
||||||
|
public static async Task Log(string message, uint ticketID = 0, Utilities.File file = null)
|
||||||
|
{
|
||||||
|
await Log(DiscordColor.Cyan, message, ticketID, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task Success(string message, uint ticketID = 0, Utilities.File file = null)
|
||||||
|
{
|
||||||
|
await Log(DiscordColor.Green, message, ticketID, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task Warn(string message, uint ticketID = 0, Utilities.File file = null)
|
||||||
|
{
|
||||||
|
await Log(DiscordColor.Orange, message, ticketID, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task Error(string message, uint ticketID = 0, Utilities.File file = null)
|
||||||
|
{
|
||||||
|
await Log(DiscordColor.Red, message, ticketID, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task Log(DiscordColor color, string message, uint ticketID = 0, Utilities.File file = null)
|
||||||
|
{
|
||||||
|
if (!IsEnabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (file != null)
|
||||||
|
{
|
||||||
|
messageBuilder.AddFile(file.fileName, file.contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
await logChannel.SendMessageAsync(messageBuilder);
|
||||||
|
}
|
||||||
|
catch (NotFoundException)
|
||||||
|
{
|
||||||
|
Logger.Error("Log channel does not exist. Channel ID: " + Config.logChannel);
|
||||||
|
}
|
||||||
|
catch (UnauthorizedException)
|
||||||
|
{
|
||||||
|
Logger.Error("No permissions to send message in log channel. Channel ID: " + Config.logChannel);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Error("Error occured trying to send message in log channel. Channel ID: " + Config.logChannel, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
Utilities.cs
10
Utilities.cs
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -14,6 +15,7 @@ public static class Extensions
|
||||||
{
|
{
|
||||||
return needles.Any(haystack.Contains);
|
return needles.Any(haystack.Contains);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool ContainsAny(this string haystack, params char[] needles)
|
public static bool ContainsAny(this string haystack, params char[] needles)
|
||||||
{
|
{
|
||||||
return needles.Any(haystack.Contains);
|
return needles.Any(haystack.Contains);
|
||||||
|
@ -24,6 +26,12 @@ public static class Utilities
|
||||||
{
|
{
|
||||||
private static readonly Random rng = new Random();
|
private static readonly Random rng = new Random();
|
||||||
|
|
||||||
|
public class File(string fileName, Stream contents)
|
||||||
|
{
|
||||||
|
public string fileName = fileName;
|
||||||
|
public Stream contents = contents;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Shuffle<T>(this IList<T> list)
|
public static void Shuffle<T>(this IList<T> list)
|
||||||
{
|
{
|
||||||
int n = list.Count;
|
int n = list.Count;
|
||||||
|
@ -95,7 +103,7 @@ public static class Utilities
|
||||||
|
|
||||||
public static DiscordColor StringToColor(string color)
|
public static DiscordColor StringToColor(string color)
|
||||||
{
|
{
|
||||||
switch (color.ToLower())
|
switch (color.ToLower(CultureInfo.InvariantCulture))
|
||||||
{
|
{
|
||||||
case "black":
|
case "black":
|
||||||
return DiscordColor.Black;
|
return DiscordColor.Black;
|
||||||
|
|
Loading…
Reference in a new issue