mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-25 22:47:04 +01:00
Fix emoji tuples out of range and no permission to read message issues
This commit is contained in:
parent
5239c2ffc0
commit
4f27dedd6f
@ -178,11 +178,10 @@ class Titan(discord.AutoShardedClient):
|
|||||||
await self.redisqueue.ban_member(guild, user)
|
await self.redisqueue.ban_member(guild, user)
|
||||||
|
|
||||||
async def on_guild_emojis_update(self, guild, before, after):
|
async def on_guild_emojis_update(self, guild, before, after):
|
||||||
|
await self.redisqueue.update_guild(guild)
|
||||||
if len(after) == 0:
|
if len(after) == 0:
|
||||||
await self.redisqueue.update_guild(guild)
|
|
||||||
await self.socketio.on_guild_emojis_update(before)
|
await self.socketio.on_guild_emojis_update(before)
|
||||||
else:
|
elif len(before) == 0:
|
||||||
await self.redisqueue.update_guild(guild)
|
|
||||||
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):
|
||||||
@ -193,8 +192,10 @@ class Titan(discord.AutoShardedClient):
|
|||||||
data = payload.data
|
data = payload.data
|
||||||
if not self.in_messages_cache(int(message_id)):
|
if not self.in_messages_cache(int(message_id)):
|
||||||
channel = self.get_channel(int(data["channel_id"]))
|
channel = self.get_channel(int(data["channel_id"]))
|
||||||
message = await channel.get_message(int(message_id))
|
me = channel.guild.get_member(self.user.id)
|
||||||
await self.on_message_edit(None, message)
|
if channel.permissions_for(me).read_messages:
|
||||||
|
message = await channel.get_message(int(message_id))
|
||||||
|
await self.on_message_edit(None, message)
|
||||||
|
|
||||||
async def on_raw_message_delete(self, payload):
|
async def on_raw_message_delete(self, payload):
|
||||||
message_id = payload.message_id
|
message_id = payload.message_id
|
||||||
@ -225,8 +226,10 @@ class Titan(discord.AutoShardedClient):
|
|||||||
message_id = payload.message_id
|
message_id = payload.message_id
|
||||||
if not self.in_messages_cache(message_id):
|
if not self.in_messages_cache(message_id):
|
||||||
channel = self.get_channel(payload.channel_id)
|
channel = self.get_channel(payload.channel_id)
|
||||||
message = await channel.get_message(message_id)
|
me = channel.guild.get_member(self.user.id)
|
||||||
await self.on_reaction_add(message.reactions[0], None)
|
if channel.permissions_for(me).read_messages:
|
||||||
|
message = await channel.get_message(message_id)
|
||||||
|
await self.on_reaction_add(message.reactions[0], None)
|
||||||
|
|
||||||
async def on_raw_reaction_remove(self, payload):
|
async def on_raw_reaction_remove(self, payload):
|
||||||
message_id = payload.message_id
|
message_id = payload.message_id
|
||||||
@ -234,17 +237,21 @@ class Titan(discord.AutoShardedClient):
|
|||||||
partial = payload.emoji
|
partial = payload.emoji
|
||||||
emoji = self._connection._upgrade_partial_emoji(partial)
|
emoji = self._connection._upgrade_partial_emoji(partial)
|
||||||
channel = self.get_channel(payload.channel_id)
|
channel = self.get_channel(payload.channel_id)
|
||||||
message = await channel.get_message(message_id)
|
me = channel.guild.get_member(self.user.id)
|
||||||
message._add_reaction({"me": payload.user_id == self.user.id}, emoji, payload.user_id)
|
if channel.permissions_for(me).read_messages:
|
||||||
reaction = message._remove_reaction({}, emoji, payload.user_id)
|
message = await channel.get_message(message_id)
|
||||||
await self.on_reaction_remove(reaction, None)
|
message._add_reaction({"me": payload.user_id == self.user.id}, emoji, payload.user_id)
|
||||||
|
reaction = message._remove_reaction({}, emoji, payload.user_id)
|
||||||
|
await self.on_reaction_remove(reaction, None)
|
||||||
|
|
||||||
async def on_raw_reaction_clear(self, payload):
|
async def on_raw_reaction_clear(self, payload):
|
||||||
message_id = payload.message_id
|
message_id = payload.message_id
|
||||||
if not self.in_messages_cache(message_id):
|
if not self.in_messages_cache(message_id):
|
||||||
channel = self.get_channel(payload.channel_id)
|
channel = self.get_channel(payload.channel_id)
|
||||||
message = await channel.get_message(message_id)
|
me = channel.guild.get_member(self.user.id)
|
||||||
await self.on_reaction_clear(message, [])
|
if channel.permissions_for(me).read_messages:
|
||||||
|
message = await channel.get_message(message_id)
|
||||||
|
await self.on_reaction_clear(message, [])
|
||||||
|
|
||||||
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:
|
||||||
|
@ -121,7 +121,12 @@ class RedisQueue:
|
|||||||
await self.push_message(message)
|
await self.push_message(message)
|
||||||
|
|
||||||
async def on_get_guild_member(self, key, params):
|
async def on_get_guild_member(self, key, params):
|
||||||
member = self.bot.get_guild(int(params["guild_id"])).get_member(int(params["user_id"]))
|
guild = self.bot.get_guild(int(params["guild_id"]))
|
||||||
|
if not guild:
|
||||||
|
await self.connection.set(key, "")
|
||||||
|
await self.enforce_expiring_key(key)
|
||||||
|
return
|
||||||
|
member = guild.get_member(int(params["user_id"]))
|
||||||
if not member:
|
if not member:
|
||||||
await self.connection.set(key, "")
|
await self.connection.set(key, "")
|
||||||
await self.enforce_expiring_key(key)
|
await self.enforce_expiring_key(key)
|
||||||
|
Loading…
Reference in New Issue
Block a user