Skip to content

Commit

Permalink
Add null check to mentionable selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlOfDuty committed Jan 20, 2025
1 parent d163261 commit ab59516
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Interviews/Interviewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DSharpPlus.Commands.Processors.SlashCommands;
using DSharpPlus.Entities;

namespace SupportBoi.Interviews;
Expand Down Expand Up @@ -131,19 +130,19 @@ public static async Task ProcessButtonOrSelectorResponse(DiscordInteraction inte
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();
}
Expand Down

0 comments on commit ab59516

Please sign in to comment.