Update member if there are discreptancies in db

This commit is contained in:
Jeremy Zhang 2018-03-25 19:56:32 +00:00
parent 19ff2ffd46
commit 70b2b266c8
2 changed files with 10 additions and 11 deletions

View File

@ -174,8 +174,6 @@ class Titan(discord.AutoShardedClient):
await self.socketio.on_guild_member_remove(member) await self.socketio.on_guild_member_remove(member)
async def on_member_update(self, memberbefore, memberafter): async def on_member_update(self, memberbefore, memberafter):
if set(memberbefore.roles) != set(memberafter.roles) or memberbefore.avatar != memberafter.avatar or memberbefore.nick != memberafter.nick or memberbefore.name != memberafter.name or memberbefore.discriminator != memberafter.discriminator or memberbefore.status != memberafter.status:
if memberbefore.status == memberafter.status:
await self.database.update_guild_member(memberafter) await self.database.update_guild_member(memberafter)
await self.socketio.on_guild_member_update(memberafter) await self.socketio.on_guild_member_update(memberafter)

View File

@ -187,6 +187,7 @@ class DatabaseInterface(object):
for mem in dbmember[1:]: for mem in dbmember[1:]:
session.delete(mem) session.delete(mem)
dbmember = dbmember[0] dbmember = dbmember[0]
if dbmember.banned != banned or dbmember.active != active or dbmember.username != member.name or dbmember.discriminator != int(member.discriminator) or dbmember.nickname != member.nick or dbmember.avatar != member.avatar or set(json.loads(dbmember.roles)) != set(list_role_ids(member.roles)):
dbmember.banned = banned dbmember.banned = banned
dbmember.active = active dbmember.active = active
dbmember.username = member.name dbmember.username = member.name