New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RoleManager#fetch()
may return null
, but this is inconsistent
#9260
Comments
Roles does this because there isn't actually an API endpoint for fetching individual roles. It fetches all of the roles, tries to resolve the id, and can return null. We could make this throw an error in the next major. Members though, no. Never returns undefined. |
I wouldn't call this a bug as there is no unexpected or unintended behaviour... return values are documented, so this shouldn't be a surprise. |
RoleManager#fetch()
may return null
, but this is inconsistent
Which package is this bug report for?
discord.js
Issue description
There is an inconsistency with fetching roles with this manager compared to the majority of other managers in discord.js.
Discord's API does not provide a way to fetch a single role... but discord.js does. discord.js fetches all roles and attempts to resolve a role and if it fails, the method returns
null
.This is inconsistent as the other managers naturally throw an error. The inconsistency here may lead to an unsuspecting encounter. It is proposed that either a custom discord.js error is thrown instead of returning
null
or stop the resolving of a singular role.Code sample
Package version
14.8.0
Node.js version
16.18.0
Operating system
Windows 10
Priority this issue should have
Low (slightly annoying)
Which partials do you have configured?
No Partials
Which gateway intents are you subscribing to?
Guilds, GuildMembers, GuildMessages, MessageContent
I have tested this issue on a development release
No
The text was updated successfully, but these errors were encountered: