Skip to content

Commit

Permalink
fix: member not being cached in Guild.getch_members in the case of …
Browse files Browse the repository at this point in the history
…`user_ids` of length one (#974)

## Summary

`Guild.get_or_fetch_members` uses `Guild.fetch_member` in case
`user_ids` contains only 1 unresolved ID. However, it does not cache the
value afterwards, which is certainly a bug that we missed.

## Checklist

<!-- Put an x inside [ ] to check it, like so: [x] -->

- [x] If code changes were made, then they have been tested
    - [ ] I have updated the documentation to reflect the changes
    - [x] I have formatted the code properly by running `pdm lint`
    - [x] I have type-checked the code by running `pdm pyright`
- [x] This PR fixes an issue
- [ ] This PR adds something new (e.g. new method or parameters)
- [ ] This PR is a breaking change (e.g. methods or parameters
removed/renamed)
- [ ] This PR is **not** a code change (e.g. documentation, README, ...)
  • Loading branch information
EQUENOS authored Mar 5, 2023
1 parent 6a1ea9d commit fe2690b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog/974.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :meth:`Guild.get_or_fetch_members` not caching anything in the case of 1 unresolved ID.
5 changes: 4 additions & 1 deletion disnake/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -4294,7 +4294,10 @@ async def get_or_fetch_members(
if len(unresolved_ids) == 1:
# fetch_member is cheaper than query_members
try:
members.append(await self.fetch_member(unresolved_ids[0]))
member = await self.fetch_member(unresolved_ids[0])
members.append(member)
if cache:
self._add_member(member)
except HTTPException:
pass
else:
Expand Down

0 comments on commit fe2690b

Please sign in to comment.