Handle webhooks update manually in socket response in hopes that Titan would update it more often

This commit is contained in:
Jeremy Zhang 2019-01-08 17:49:17 +00:00
parent f50b57ff91
commit ef9a97a03a

View File

@ -184,8 +184,8 @@ class Titan(discord.AutoShardedClient):
else: else:
await self.socketio.on_guild_emojis_update(after) await self.socketio.on_guild_emojis_update(after)
async def on_webhooks_update(self, channel): # async def on_webhooks_update(self, channel):
await self.redisqueue.update_guild(channel.guild) # await self.redisqueue.update_guild(channel.guild)
async def on_raw_message_edit(self, payload): async def on_raw_message_edit(self, payload):
message_id = payload.message_id message_id = payload.message_id
@ -254,6 +254,14 @@ class Titan(discord.AutoShardedClient):
message = await channel.get_message(message_id) message = await channel.get_message(message_id)
await self.on_reaction_clear(message, []) 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): def in_messages_cache(self, msg_id):
for msg in self._connection._messages: for msg in self._connection._messages:
if msg.id == msg_id: if msg.id == msg_id: