Add null check to mentionable selectors

This commit is contained in:
Toastie 2025-02-04 20:14:16 +13:00
parent 2242e6e3bf
commit 9d30a2d415
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7

View file

@ -5,7 +5,6 @@ using System.Collections.Specialized;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities;
namespace SupportChild.Interviews;
@ -131,19 +130,19 @@ public static class Interviewer
case DiscordComponentType.RoleSelect:
case DiscordComponentType.ChannelSelect:
case DiscordComponentType.MentionableSelect:
if (interaction.Data.Resolved.Roles.Any())
if (interaction?.Data?.Resolved?.Roles?.Any() ?? false)
{
answer = interaction.Data.Resolved.Roles.First().Value.Mention;
}
else if (interaction.Data.Resolved.Users.Any())
else if (interaction.Data?.Resolved?.Users?.Any() ?? false)
{
answer = interaction.Data.Resolved.Users.First().Value.Mention;
}
else if (interaction.Data.Resolved.Channels.Any())
else if (interaction.Data?.Resolved?.Channels?.Any() ?? false)
{
answer = interaction.Data.Resolved.Channels.First().Value.Mention;
}
else if (interaction.Data.Resolved.Messages.Any())
else if (interaction.Data?.Resolved?.Messages?.Any() ?? false)
{
answer = interaction.Data.Resolved.Messages.First().Value.Id.ToString();
}