From 46f5594763369628a43f5df79c7eb9c3d8ca359a Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 16 Sep 2017 16:53:39 +0000 Subject: [PATCH] Filter presence updates to prevent updating everything, which might create cpu hog --- discordbot/titanembeds/bot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/discordbot/titanembeds/bot.py b/discordbot/titanembeds/bot.py index 7353b7a..cfca3f4 100644 --- a/discordbot/titanembeds/bot.py +++ b/discordbot/titanembeds/bot.py @@ -168,8 +168,10 @@ class Titan(discord.Client): await self.socketio.on_guild_member_remove(member) async def on_member_update(self, memberbefore, memberafter): - await self.database.update_guild_member(memberafter) - await self.socketio.on_guild_member_update(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.status != memberafter.status: + if memberbefore.status == memberafter.status: + await self.database.update_guild_member(memberafter) + await self.socketio.on_guild_member_update(memberafter) async def on_member_ban(self, member): if self.user.id == member.id: