Discord.Net icon indicating copy to clipboard operation
Discord.Net copied to clipboard

[Bug]: SlashCommand with RequireRole throws a obj not set exception

Open query-wow opened this issue 3 years ago • 4 comments

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
image

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

query-wow avatar Nov 17 '22 09:11 query-wow

Sorry for a late response Can you still reproduce the issue on v3.11.0?

Misha-133 avatar Jul 05 '23 23:07 Misha-133

@Misha-133 will check and see if it still happens

query-wow avatar Jul 06 '23 10:07 query-wow

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.

christianbernds avatar Oct 01 '23 20:10 christianbernds

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.

christianbernds avatar Nov 26 '23 13:11 christianbernds