using System.Collections.Generic; using System.Threading.Tasks; using DSharpPlus.Entities; using DSharpPlus.Interactivity; using DSharpPlus.Interactivity.Extensions; using DSharpPlus.SlashCommands; using DSharpPlus.SlashCommands.Attributes; namespace SupportChild.Commands; public class ListUnassignedCommand : ApplicationCommandModule { [SlashRequireGuild] [SlashCommand("listunassigned", "Lists unassigned tickets.")] public async Task OnExecute(InteractionContext command) { if (!Database.TryGetAssignedTickets(0, out List unassignedTickets)) { await command.CreateResponseAsync(new DiscordEmbedBuilder { Color = DiscordColor.Green, Description = "There are no unassigned tickets." }); return; } List listItems = new List(); foreach (Database.Ticket ticket in unassignedTickets) { listItems.Add("**" + ticket.DiscordRelativeTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n"); } List embeds = new List(); foreach (string message in Utilities.ParseListIntoMessages(listItems)) { embeds.Add(new DiscordEmbedBuilder { Title = "Unassigned tickets: ", Color = DiscordColor.Green, Description = message }); } // Add the footers for (int i = 0; i < embeds.Count; i++) { embeds[i].Footer = new DiscordEmbedBuilder.EmbedFooter { Text = $"Page {i + 1} / {embeds.Count}" }; } List listPages = new List(); foreach (DiscordEmbedBuilder embed in embeds) { listPages.Add(new Page("", embed)); } await command.Interaction.SendPaginatedResponseAsync(true, command.User, listPages); } }