From ef9a97a03a0adc3e542368e657e1162d44cc1798 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Tue, 8 Jan 2019 17:49:17 +0000 Subject: [PATCH] Handle webhooks update manually in socket response in hopes that Titan would update it more often --- discordbot/titanembeds/bot.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/discordbot/titanembeds/bot.py b/discordbot/titanembeds/bot.py index 1d4b0cd..c81b50b 100644 --- a/discordbot/titanembeds/bot.py +++ b/discordbot/titanembeds/bot.py @@ -184,8 +184,8 @@ class Titan(discord.AutoShardedClient): else: await self.socketio.on_guild_emojis_update(after) - async def on_webhooks_update(self, channel): - await self.redisqueue.update_guild(channel.guild) + # async def on_webhooks_update(self, channel): + # await self.redisqueue.update_guild(channel.guild) async def on_raw_message_edit(self, payload): message_id = payload.message_id @@ -254,6 +254,14 @@ class Titan(discord.AutoShardedClient): message = await channel.get_message(message_id) await self.on_reaction_clear(message, []) + async def on_socket_response(self, msg): + if "op" in msg and "t" in msg and msg["op"] == 0: + if msg["t"] == "WEBHOOKS_UPDATE": + guild_id = int(msg["d"]["guild_id"]) + guild = self.get_guild(guild_id) + if guild: + await self.redisqueue.update_guild(guild) + def in_messages_cache(self, msg_id): for msg in self._connection._messages: if msg.id == msg_id: