Discord.Net
Discord.Net copied to clipboard
[Bug]: SlashCommand with RequireRole throws a obj not set exception
Check The Docs
- [X] I double checked the docs and couldn't find any useful information.
Verify Issue Source
- [X] I verified the issue was caused by Discord.Net.
Check your intents
- [X] I double checked that I have the required intents.
Description
Using a slash command with required role throws an object not set on the precondition check

Version
3.8.1
Working Version
No response
Logs
at Discord.Interactions.RequireRoleAttribute.CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services)
at Discord.Interactions.CommandInfo1.<>c__DisplayClass40_0.<<CheckPreconditionsAsync>g__CheckGroups|0>d.MoveNext() at Discord.Interactions.CommandInfo1.<CheckPreconditionsAsync>d__40.MoveNext()
at Discord.Interactions.CommandInfo`1.<ExecuteInternalAsync>d__42.MoveNext()
Sample
[SlashCommand("ping", "Pong")]
[RequireRole(<id of role>)]
public async Task Ping()
{
await RespondAsync("Pong");
}
Packages
Discord.Net 3.8.1
Sorry for a late response Can you still reproduce the issue on v3.11.0?
@Misha-133 will check and see if it still happens
Hi, i can still reproduce this issue.
StackTrace:
Something went wrong while executing interaction System.NullReferenceException: Object reference not set to an instance of an object. at Discord.Interactions.RequireRoleAttribute.<>c__DisplayClass12_0.<CheckRequirementsAsync>b__0(UInt64 x) at System.Linq.Enumerable.SelectIListIterator2.MoveNext()
at System.Linq.Enumerable.Contains[TSource](IEnumerable1 source, TSource value, IEqualityComparer1 comparer)
at System.Linq.Enumerable.Contains[TSource](IEnumerable1 source, TSource value) at Discord.Interactions.RequireRoleAttribute.CheckRequirementsAsync(IInteractionContext context, ICommandInfo commandInfo, IServiceProvider services) at Discord.Interactions.CommandInfo1.<>c__DisplayClass45_0.<<CheckPreconditionsAsync>g__CheckGroups|0>d.MoveNext()
--- End of stack trace from previous location ---
at Discord.Interactions.CommandInfo1.CheckPreconditionsAsync(IInteractionContext context, IServiceProvider services) at Discord.Interactions.CommandInfo1.ExecuteInternalAsync(IInteractionContext context, IServiceProvider services)
at Discord.Interactions.CommandInfo1.ExecuteInternalAsync(IInteractionContext context, IServiceProvider services) at Discord.Interactions.CommandInfo1.ExecuteInternalAsync(IInteractionContext context, IServiceProvider services)
at Discord.Interactions.CommandInfo1.ExecuteAsync(IInteractionContext context, IServiceProvider services) at Discord.Interactions.SlashCommandInfo.ExecuteAsync(IInteractionContext context, IServiceProvider services) at Discord.Interactions.InteractionService.ExecuteSlashCommandAsync(IInteractionContext context, ISlashCommandInteraction interaction, IServiceProvider services) at Discord.Interactions.InteractionService.ExecuteCommandAsync(IInteractionContext context, IServiceProvider services) at DiscordBot.DiscordBotService.ClientOnInteractionCreatedAsync(SocketInteraction interaction) in E:\github\DiscordBotService.cs:line 82 at DiscordBot.DiscordBotService.ClientOnInteractionCreatedAsync(SocketInteraction interaction) in E:\github\DiscordBotService.cs:line 105
In my case this error only occurs within arm32v7 container on a old raspberry pi 2.
Docker base image is a alpine linux for arm32v7.
Dev setup on a windows 11 works as a charm, only in container it is crashing with this error.
Hi, I figured out that my problem is caused by the alpine images. Neither aspnet:8.0-alpine or aspnet:8.0-alpine-arm32v7 are working. Neverless the base aspnet:8.0 image is working correctly.