diff options
| author | 2020-02-07 11:30:52 -0800 | |
|---|---|---|
| committer | 2020-02-12 10:07:57 -0800 | |
| commit | 548f258314513cc41a0e4339b6eaa06be75a8f5d (patch) | |
| tree | 89e67101a56b13fcab64cd70285b02eb8c921275 | |
| parent | Sync tests: test sync users command (diff) | |
Sync: only update in_guild field when a member leaves
The member and user update listeners should already be detecting and
updating other fields so by the time a user leaves, the rest of the
fields should be up-to-date.
* Dedent condition which was indented too far
| -rw-r--r-- | bot/cogs/sync/cog.py | 22 | 
1 files changed, 6 insertions, 16 deletions
diff --git a/bot/cogs/sync/cog.py b/bot/cogs/sync/cog.py index 66ffbabf9..ee3cccbfa 100644 --- a/bot/cogs/sync/cog.py +++ b/bot/cogs/sync/cog.py @@ -66,10 +66,10 @@ class Sync(Cog):      async def on_guild_role_update(self, before: Role, after: Role) -> None:          """Syncs role with the database if any of the stored attributes were updated."""          if ( -                before.name != after.name -                or before.colour != after.colour -                or before.permissions != after.permissions -                or before.position != after.position +            before.name != after.name +            or before.colour != after.colour +            or before.permissions != after.permissions +            or before.position != after.position          ):              await self.bot.api_client.put(                  f'bot/roles/{after.id}', @@ -120,18 +120,8 @@ class Sync(Cog):      @Cog.listener()      async def on_member_remove(self, member: Member) -> None: -        """Updates the user information when a member leaves the guild.""" -        await self.bot.api_client.put( -            f'bot/users/{member.id}', -            json={ -                'avatar_hash': member.avatar, -                'discriminator': int(member.discriminator), -                'id': member.id, -                'in_guild': False, -                'name': member.name, -                'roles': sorted(role.id for role in member.roles) -            } -        ) +        """Set the in_guild field to False when a member leaves the guild.""" +        await self.patch_user(member.id, updated_information={"in_guild": False})      @Cog.listener()      async def on_member_update(self, before: Member, after: Member) -> None:  |