Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
fix: only adjust member count if guild is found (#742)
Browse files Browse the repository at this point in the history
* fix: only adjust member count if guild is found

* refactor: don't get guild twice

Co-authored-by: Astrea49 <[email protected]>
  • Loading branch information
AstreaTSS and AstreaTSS authored Jan 1, 2023
1 parent f28efa2 commit b2f7632
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions naff/api/events/processors/member_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class MemberEvents(EventMixinTemplate):
async def _on_raw_guild_member_add(self, event: "RawGatewayEvent") -> None:
g_id = event.data.pop("guild_id")
member = self.cache.place_member_data(g_id, event.data)
guild = self.cache.get_guild(g_id)
guild.member_count += 1
if guild := self.cache.get_guild(g_id):
guild.member_count += 1
self.dispatch(events.MemberAdd(g_id, member))

@Processor.define()
Expand All @@ -27,8 +27,8 @@ async def _on_raw_guild_member_remove(self, event: "RawGatewayEvent") -> None:
member = self.cache.get_member(g_id, user.id)

self.cache.delete_member(g_id, user.id)
guild = self.cache.get_guild(g_id)
guild.member_count -= 1
if guild := self.cache.get_guild(g_id):
guild.member_count -= 1

self.dispatch(events.MemberRemove(g_id, member or user))

Expand Down

0 comments on commit b2f7632

Please sign in to comment.