diff --git a/Commands/ListCommand.cs b/Commands/ListCommand.cs index 32c86e4..f18e1b2 100644 --- a/Commands/ListCommand.cs +++ b/Commands/ListCommand.cs @@ -16,7 +16,7 @@ public class ListCommand [Command("list")] [Description("Lists tickets opened by a user.")] public async Task OnExecute(SlashCommandContext command, - [Parameter("user")][Description("(Optional) The user to get tickets by.")] DiscordUser user = null) + [Parameter("user")][Description("(Optional) The user to get tickets by, yourself by default.")] DiscordUser user = null) { DiscordUser listUser = user == null ? command.User : user; diff --git a/Commands/ListOpen.cs b/Commands/ListOpen.cs index 9128988..ce00f4b 100644 --- a/Commands/ListOpen.cs +++ b/Commands/ListOpen.cs @@ -1,10 +1,13 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; +using System.Linq; using System.Threading.Tasks; using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; using DSharpPlus.Interactivity; using DSharpPlus.Interactivity.Extensions; @@ -27,10 +30,32 @@ public class ListOpen return; } + // Get all channels in all guilds the bot is part of + List allChannels = new List(); + foreach (KeyValuePair guild in SupportChild.client.Guilds) + { + try + { + allChannels.AddRange(await guild.Value.GetChannelsAsync()); + } + catch (Exception) { /*ignored*/ } + } + List listItems = new List(); foreach (Database.Ticket ticket in openTickets) { - listItems.Add("**" + ticket.DiscordRelativeTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n"); + try + { + DiscordChannel channel = allChannels.FirstOrDefault(c => c.Id == ticket.channelID); + if (channel != null) + { + if (command.Member!.PermissionsIn(channel).HasPermission(DiscordPermissions.AccessChannels)) + { + listItems.Add("**" + ticket.DiscordRelativeTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n"); + } + } + } + catch (NotFoundException) { /*ignored*/ } } List embeds = new List(); diff --git a/Commands/ListUnassignedCommand.cs b/Commands/ListUnassignedCommand.cs index 3ff45e6..817107f 100644 --- a/Commands/ListUnassignedCommand.cs +++ b/Commands/ListUnassignedCommand.cs @@ -1,10 +1,13 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; +using System.Linq; using System.Threading.Tasks; using DSharpPlus.Commands; using DSharpPlus.Commands.ContextChecks; using DSharpPlus.Commands.Processors.SlashCommands; using DSharpPlus.Entities; +using DSharpPlus.Exceptions; using DSharpPlus.Interactivity; using DSharpPlus.Interactivity.Extensions; @@ -27,10 +30,32 @@ public class ListUnassignedCommand return; } + // Get all channels in all guilds the bot is part of + List allChannels = new List(); + foreach (KeyValuePair guild in SupportChild.client.Guilds) + { + try + { + allChannels.AddRange(await guild.Value.GetChannelsAsync()); + } + catch (Exception) { /*ignored*/ } + } + List listItems = new List(); foreach (Database.Ticket ticket in unassignedTickets) { - listItems.Add("**" + ticket.DiscordRelativeTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n"); + try + { + DiscordChannel channel = allChannels.FirstOrDefault(c => c.Id == ticket.channelID); + if (channel != null) + { + if (command.Member!.PermissionsIn(channel).HasPermission(DiscordPermissions.AccessChannels)) + { + listItems.Add("**" + ticket.DiscordRelativeTime() + ":** <#" + ticket.channelID + "> by <@" + ticket.creatorID + ">\n"); + } + } + } + catch (NotFoundException) { /*ignored*/ } } List embeds = new List();