You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
constrole=awaitguild.roles.fetch(roleId);// If the roleId does not exist, role is nullconstmember=awaitguild.members.fetch(memberId);// If the memberId does not exist, an error is thrown
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.
If memberId is defined but not a member of the guild, that fetch will throw an Unknown Member API error.
If memberId is undefined, it will fetch all members in the guild as if you didn't pass any parameters.
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: