Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

DiscordGuild.GetRoleAsync throws NullReferenceException if called on a guild the bot is in before GuildDownloadCompleted has fired #2372

Copy link
Copy link
@Autoquark

Description

@Autoquark
Issue body actions

Summary

Opening an issue as per @Plerx2493 's request on the discord. Under some circumstances role related properties & methods on DiscordGuild can throw due to the "Roles" property being null if accessed before GuildDownloadCompleted fires

What version of the library are you using?

v5.0.0-nightly (make sure you are using the latest nightly!)

What .NET version are you using? Make sure to use the latest patch release for your major version.

.NET 9.0

Operating System

Windows 11

Reproduction Steps

  1. Run a bot that is a member of at least one guild
  2. After connecting, immediately call DiscordClient.GetGuildAsync()
  3. On one of the returned guilds, call DiscordGuild.GetRoleAsync passing the guild id or access DiscordGuild.EveryoneRole
  4. NullReferenceException will be thrown

Trace Logs


Exceptions or other error messages

Anything else you'd like to share

No response

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.