Skip to content
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

Naming of XChannelEditSpec.Builder#addPermissionOverwrite is potentially confusing #1010

Open
Laarryy opened this issue Sep 26, 2021 · 2 comments
Labels
area/core Related to core module: events, entities, clients, specs feature-request Request for a new library feature or behavior
Milestone

Comments

@Laarryy
Copy link

Laarryy commented Sep 26, 2021

Feature Description:

Modify the channel#addPermissionOverwrite method to internally fetch a list of all existing permission overwrites, add the one provided, and send the whole package to discord. This is opposed to current behaviour which is nearly the same as channel#addAllPermissionOverwrites except it only sends the one provided, deleting all others.

Justification:

At the moment, the textChannel#addPermissionOverwrite method will send an empty set with only the single specified permission overwrite to discord. By instead fetching all existing overwrites, adding the one provided, and sending the entire set, the method will be true to its name and will not delete all other existing overwrites. This will also make modifying channel permissions much simpler as the user would not have to get the list, create a new one with the added overwrite, and send them all manually.

@darichey darichey added area/core Related to core module: events, entities, clients, specs feature-request Request for a new library feature or behavior labels Sep 26, 2021
@darichey darichey added this to the 3.2.x Backlog milestone Sep 26, 2021
@darichey
Copy link
Member

To clarify: there is no TextChannel#addPermissionOverwrite. I believe you are looking at XChannelEditSpec.Builder#addPermissionOverwrite which, while maybe somewhat confusing, is working properly. The builder is building a new list of overwrites to send to Discord. You're adding to that list, but it doesn't contain all of the existing overwrites.

I don't think it would be wise (or even possible) to try to get that list to contain all of the existing overwrites by default. Instead, it would be nice if we had some kind of utility method that could signal to the request builder that the channel's existing overwrites should be included.

Unfortunately, the more I think about this, the more difficult it gets. This leads to a wider discussion about utility methods in specs (like button editing/disabling, to provide another example), potentially "polluting" the fields in the spec generator interfaces, and not painting ourselves into a corner for when we eventually want to try to move specs down to be usable in the rest module.

@Laarryy
Copy link
Author

Laarryy commented Sep 26, 2021

An alternative suggestion is always simply renaming the editspec's addPermissionOverwrite method to some name that communicates how addPermissionOverwrite will delete all other overwrites. overwritePermissionOverwrites is a funny name but probably not too wise. Nevertheless, a note in the javadocs about what that method actually does would be incredibly useful 😄

@darichey darichey changed the title Make addPermissionOverwrite do what it says Naming of XChannelEditSpec.Builder#addPermissionOverwrite is potentially confusing Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core Related to core module: events, entities, clients, specs feature-request Request for a new library feature or behavior
Projects
None yet
Development

No branches or pull requests

2 participants