Added tickets where the user has left to /admin listinvalid
This commit is contained in:
parent
851a3c949c
commit
e8bf4d3004
2 changed files with 25 additions and 7 deletions
|
@ -47,16 +47,27 @@ public class AdminCommands
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check which tickets channels no longer exist
|
// Check which tickets channels no longer exist
|
||||||
List<string> listItems = new List<string>();
|
List<string> invalidTickets = new List<string>();
|
||||||
foreach (Database.Ticket ticket in openTickets)
|
foreach (Database.Ticket ticket in openTickets)
|
||||||
{
|
{
|
||||||
if (allChannels.All(channel => channel.Id != ticket.channelID))
|
DiscordChannel channel = allChannels.FirstOrDefault(c => c.Id == ticket.channelID);
|
||||||
|
if (channel == null)
|
||||||
{
|
{
|
||||||
listItems.Add("ID: **" + ticket.id.ToString("00000") + ":** <#" + ticket.channelID + ">\n");
|
invalidTickets.Add("**`ticket-" + ticket.id.ToString("00000") + ":`** Channel no longer exists (<#" + ticket.channelID + ">)\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await channel.Guild.GetMemberAsync(ticket.creatorID);
|
||||||
|
}
|
||||||
|
catch (NotFoundException)
|
||||||
|
{
|
||||||
|
invalidTickets.Add("**`ticket-" + ticket.id.ToString("00000") + ":`** Creator has left (<#" + ticket.channelID + ">)\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listItems.Count == 0)
|
if (invalidTickets.Count == 0)
|
||||||
{
|
{
|
||||||
await command.RespondAsync(new DiscordEmbedBuilder
|
await command.RespondAsync(new DiscordEmbedBuilder
|
||||||
{
|
{
|
||||||
|
@ -67,7 +78,7 @@ public class AdminCommands
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DiscordEmbedBuilder> embeds = new List<DiscordEmbedBuilder>();
|
List<DiscordEmbedBuilder> embeds = new List<DiscordEmbedBuilder>();
|
||||||
foreach (string message in Utilities.ParseListIntoMessages(listItems))
|
foreach (string message in Utilities.ParseListIntoMessages(invalidTickets))
|
||||||
{
|
{
|
||||||
embeds.Add(new DiscordEmbedBuilder
|
embeds.Add(new DiscordEmbedBuilder
|
||||||
{
|
{
|
||||||
|
@ -145,7 +156,7 @@ public class AdminCommands
|
||||||
[Command("unsetticket")]
|
[Command("unsetticket")]
|
||||||
[Description("Deletes a ticket from the ticket system without deleting the channel.")]
|
[Description("Deletes a ticket from the ticket system without deleting the channel.")]
|
||||||
public async Task UnsetTicket(SlashCommandContext command,
|
public async Task UnsetTicket(SlashCommandContext command,
|
||||||
[Parameter("ticket-id")][Description("(Optional) Ticket to unset. Uses the channel you are in by default.")] long ticketID = 0)
|
[Parameter("ticket-id")][Description("(Optional) Ticket to unset. Uses the channel you are in by default. Use ticket ID, not channel ID!")] long ticketID = 0)
|
||||||
{
|
{
|
||||||
Database.Ticket ticket;
|
Database.Ticket ticket;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
|
using DSharpPlus;
|
||||||
|
using DSharpPlus.Exceptions;
|
||||||
|
|
||||||
namespace SupportChild;
|
namespace SupportChild;
|
||||||
|
|
||||||
|
@ -76,7 +78,12 @@ public class Logger : ILogger
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Ratelimit messages are usually warnings, but they are unimportant in this case so downgrade them to debug.
|
// Ratelimit messages are usually warnings, but they are unimportant in this case so downgrade them to debug.
|
||||||
if (formatter(state, exception).StartsWith("Hit Discord ratelimit on route "))
|
if (formatter(state, exception).StartsWith("Hit Discord ratelimit on route ") && logLevel == LogLevel.Warning)
|
||||||
|
{
|
||||||
|
logLevel = LogLevel.Debug;
|
||||||
|
}
|
||||||
|
// The bot will handle NotFoundExceptions on its own, downgrade to debug
|
||||||
|
else if (exception is NotFoundException && eventId == LoggerEvents.RestError)
|
||||||
{
|
{
|
||||||
logLevel = LogLevel.Debug;
|
logLevel = LogLevel.Debug;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue