feat: Implement better get_or_fetch
Summary
Information
- [ ] This PR fixes an issue.
- [x] This PR adds something new (e.g. new method or parameters). #1856
- [ ] This PR is a breaking change (e.g. methods or parameters removed/renamed).
- [ ] This PR is not a code change (e.g. documentation, README, typehinting, examples, ...).
Checklist
- [x] I have searched the open pull requests for duplicates.
- [x] If code changes were made then they have been tested.
- [x] I have updated the documentation to reflect the changes.
- [x] If
type: ignorecomments were used, a comment is also left explaining why. - [x] I have updated the changelog to include these changes.
feat from #1856
still not ready have some bug like : NameError: name 'VoiceChannel' is not defined ig because of the type checking, i'll have to find a way to import it without circular import
@Lumabots You can import it inside of the function where you use it directly instead of importing it at the top
@Lumabots You can import it inside of the function where you use it directly instead of importing it at the top
Well ig the issue come from the definition for the typevar, so will that resolve it ?
should be ready for review
just need to specify that this is breaking inside the changelog cos of modification of get_or_fetch and removal of get_or_fetch_user
ready for review
@plun1331 concerning this review, this the shortcut from the guild and client has only some small change like member and user/guild, should i keep each doc different ? or should i just let that slide and so use utils.copy doc and import from utils the fetchable ?
@plun1331 concerning this review, this the shortcut from the guild and client has only some small change like member and user/guild, should i keep each doc different ? or should i just let that slide and so use utils.copy doc and import from utils the fetchable ?
copy doc would work, but im realizing that get_or_fetch has an extra param that the wrapper methods don't, so maybe it would be better to write separate docs for all of them
and yes, still import the _FETCHABLE type from utils
maybe i could also handle in case the id is none by just retuning None, this could help as a helper fonction to not have to check with a if ... is not None, what are your thoughts ?
Merge conflicts
fixed
Merge conflicts again 😂
Maybe an unintended side-effect, Guild + AppEmoji is valid:
emoji = await utils.get_or_fetch(<Guild>, discord.AppEmoji, <valid guild emoji id>)
print(type(emoji)) # discord.GuildEmoji
Tested and works, outside of the 2 comments above.