#Permissions object throwing NullReferenceException

1 messages · Page 1 of 1 (latest)

fluid sphinx
#

Problem

Hi, I'm facing an issue in 5.0.0-nightly-01579 where accessing the Permissions property on the DiscordMember object throws a NullReferenceException.

Exceptions

[20:05:20 ERR] Event handler exception for event READY thrown from System.Threading.Tasks.Task <<Main>$>b__0(DSharpPlus.DiscordClient, DSharpPlus.EventArgs.ReadyEventArgs
) (defined in Program+<>c__DisplayClass0_0)
System.NullReferenceException: Object reference not set to an instance of an object.
   at DSharpPlus.Entities.DiscordMember.GetPermissions()
   at DSharpPlus.Entities.DiscordMember.get_Permissions()
   at Program.<>c__DisplayClass0_0.<<<Main>$>b__0>d.MoveNext() in C:\Users\mcpem\RiderProjects\project\Program.cs:line 31
--- End of stack trace from previous location ---
   at DSharpPlus.AsyncEvents.AsyncEvent`2.<>c__DisplayClass7_0.<<InvokeAsync>b__0>d.MoveNext()

Expected Result

It gives me the Permissions object.

Code Samples

Here is nothing special, I loop through the DiscordClient's guilds and want to check the permissions, but it throws the Exception. I've checked that the DiscordMember object (clientMember) is not null, just the Permissions object.

foreach (var guild in client.Guilds.Values)
{
    var clientMember = await guild.GetMemberAsync(client.CurrentUser.Id);
    Console.WriteLine(clientMember.Permissions); // throws NullReferenceException
}
strange thicket
#

Permissions can't be null, that's very odd behaviour

#

although there's actually quite a lot in this that could be null

fluid sphinx
#

maybe my .net environment is just outdated

strange thicket
#

5.0 hard depends on .NET 7, which is the latest release

fluid sphinx
#

okay, checked that and it isn't outdated

strange thicket
#

theoretically nothing here should throw, unless our cache is broken

#

which to be clear is very well possible

#

could you check with a debug build of the library (cloning and self-building)? we'd need the line that throws to properly debug

fluid sphinx
#

okay

#

the master branch?

halcyon hornet
#

hans tag ready event

timber ivyBOT
# halcyon hornet hans tag ready event

msfrown Specified tag was not found. Here are some suggestions:

threads, really-fucked-up, read the error, what am i reading, read, ready-event, event-deadlock

halcyon hornet
#

h

#

Hans tag ready-event

timber ivyBOT
# halcyon hornet Hans tag ready-event

YOU PROBABLY AREN'T LOOKING FOR THE READY EVENT*. The ready event does NOT mean your client is "ready".

Chances are it's not what you want. If you want member/guild information, the Ready event is NOT what you want.

If you want guild/members: Use GuildDownloadCompleted instead.

The Ready event on the client only signals that your client has completed a handshake with the gateway, and it's ready to start streaming payloads to you.
*This isn't to say you should never use it, but for a vast majority of uses, there is no point in using this event, and it simply exists for completeness and correctness.

Gateway documentation: https://discord.dev/topics/gateway-events#ready

halcyon hornet
#

This also applies for permissions

fluid sphinx
#

ah okay

#

so the "ready" event is just what discord sends

#

after the initial handshake

#

thank you very much

strange thicket