-
-
Notifications
You must be signed in to change notification settings - Fork 482
Add Guild._fetch_role()
private method to support proper handling of role mentionable in slash command options
#1101
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
Add Guild._fetch_role()
private method to support proper handling of role mentionable in slash command options
#1101
Conversation
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps the note should be changed to This method is an API call. For general usage, consider using :attr:`get_role` instead.
I feel like making this a private method "_fetch_role" would be more correct (And add handling for that inside get_or_fetch). This currently doesn't reflect the api well and shouldn't really be a method we promote, as it's rather "fetch_roles_and_filter_for_one_role" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my last comment
Good point. I'll update with those changes and test it out. Setting to draft for now. |
…dd corresponding handling in `utils.get_or_fetch`
Guild.fetch_role()
method to support proper handling of role mentionable in slash command optionsGuild._fetch_role()
private method to support proper handling of role mentionable in slash command options
This is ready for review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I downloaded this branch and It fixed the problem for me!
Summary
This adds a new private method
Guild._fetch_role()
which allowsutils.get_or_fetch
to work with roles properly. Previously it did not work because there was only afetch_roles
method, notfetch_role
. As part of this change,utils.get_or_fetch
was also updated to use private_fetch
methods if anAttributeError
is raised for any object that does not have afetch_*
method. This has an added benefit of allowing us to more easily add private _fetch methods on other objects if we need to in the future.This also fixes #906 by having the "mentionable" option type check for first a user, then a role if a user is not found. This required the above described addition of
Guild._fetch_fole()
to work properly.Checklist
type: ignore
comments were used, a comment is also left explaining why