Remove permissions getters #5244
Replies: 8 comments
-
In my opinion, |
Beta Was this translation helpful? Give feedback.
-
We were talking about a request to add required permissions per method to the library some time back and also considered the option to do permission handling with discord.js (throwing permission missing errors to prevent unnecessary failed API calls) Back then the decision was that discord.js should neither handle nor document upstream permission requirements (discord API docs) to instead let the developer handle it themselves. For that exact reason i was rather astonished that the above mentioned permission check getters started to appear. I still am of the opinion that discord.js should not handle permissions for the developer, however if it is actually something we decide we want to do we should go the route of throwing permission errors. With passing time the clutter by likewise getters has become more and more noticeable. If we should decide to stick to this approach however we should strive for completeness, to which quite honestly it is currently not apparent to me where it should end. Should discord decide to change permission requirements this will break library functionality in the stable branch (which they have done before), a perspective that should also be considered. |
Beta Was this translation helpful? Give feedback.
-
I agree with @anandre, but I will attempt to provide some additional justification. Getters that perform more than trivial permissions checks are useful utilities for bot developers which this library should provide. There is no reason to remove them because we can clearly define what is out of scope: any trivial permission check can be done easily by the bot developer based on the particular permissions they might need at the time. For example, it's relatively simple to check if the client can react to a message (just check for permissions in the channel) but significantly less so in the example provided by @anandre.
Considering that it's taken over a year for the next major to be released (which still hasn't happened), I understand your concern about not being able to update the library quickly in response to changes on Discord's end. However, that is entirely our choice and we could easily release a patch should we decide it's necessary.
This is a slippery slope and one we don't necessarily need to go down if we decide to keep some utility permissions getters. There is a difference between completely disallowing functionality and giving the developer information that they can choose to use. |
Beta Was this translation helpful? Give feedback.
-
I'd suggest that if we do want to remove getters, similar utility function should be provided elsewhere in the lib. For example, something like a While I agree with the premise that we don't need to hold developers hands all the time, I'm not a fan of taking functionality away, nor intentionally not providing useful utilities that everyone could benefit from. |
Beta Was this translation helpful? Give feedback.
-
I agree with @anandre on the issue that kickable and bannable do some important checks and should stay, however, i do not believe simple getters which do a single check like |
Beta Was this translation helpful? Give feedback.
-
While I don't mind having getters at all, |
Beta Was this translation helpful? Give feedback.
-
If we realistically look at the getters that are nothing more than single checks developers could do on their own:
Getters which are another getter + a check:
Other questionable getters, but do have some complexity
Fairly complex getters that should probably stay
Good chance I've missed some. |
Beta Was this translation helpful? Give feedback.
-
As it stands currently the maintainability / cost isn't too high for those getters. We should just be careful about adding new ones in the future to avoid increasing cost and clutter. |
Beta Was this translation helpful? Give feedback.
-
Permissions getters such as
GuildMember#kickable
andGuildMember#bannable
serve purposes which are out of the scope of what discord.js is responsible for. Additionally they cloud the source code, typings, and documentation. There are a total of around 31 of these getters, most of them are simply a check for the client's permissions which can easily be done by the user. Discord.js already provides great permissions classes and methods, there is no need for these getters. Finally, these getters add uncertainty of what should be added, should something likeTextChannel#sendable
be added? something likeGuild#deletable
if the client owns the guild?Describe the ideal solution
Completely remove the getters.
Describe alternatives you've considered
Rework the getters in some way to be centralized somewhere else.
edit: just to be clear, this is mostly meant to be an issue to talk about how these permissions getters are kind of a problem, and how to deal with them. Not exactly "there is a dire need to completely nuke them".
Beta Was this translation helpful? Give feedback.
All reactions