fix(bot): 🐛 Message deletes not working.

This commit is contained in:
Nyeki.py
2024-10-20 22:00:10 -03:00
parent b5fddf17f9
commit 9e81978fba
3 changed files with 9 additions and 22 deletions
+8 -20
View File
@@ -887,21 +887,21 @@ class Calls(base.Cog):
message_id = payload.message_id
channel_id = payload.channel_id
is_on_call = await redis.sismember(
constants.CHANNELS_ONCALL_SET, str(channel_id)
)
channel = await models.Channel.get(id=channel_id)
if not is_on_call:
if channel.call_id is None:
return
message = await models.Message.get_or_none(id=message_id).select_related(
"propagation_channel"
message_json = await redis.hget(
constants.CALL_MESSAGES_TEMPLATE % channel.call_id, message_id
)
if message is None:
if message_json is None:
return
other_channel = message.propagation_channel
message = models.Message(**orjson.loads(message_json))
other_channel = await models.Channel.get(id=message.propagation_channel_id)
if other_channel.call_id != message.call_id:
return
@@ -916,18 +916,6 @@ class Calls(base.Cog):
# This message was already deleted.
pass
for replying_message in await models.Message.filter(
replying_to_id=message_id
).exclude(propagation_channel_id=channel_id):
try:
await webhook.edit_message(
replying_message.propagation_id, embed=None
)
except errors.DiscordException:
# This message was deleted.
pass
@commands.Cog.listener()
@commands.guild_only()
@transactions.atomic()
-2
View File
@@ -33,8 +33,6 @@ async def ReplyEmbed(
reference.message_id,
)
print(constants.CALL_MESSAGE_FROM_PROPAGATION_TEMPLATE % call_id)
if message_id is not None:
unflushed_message = await redis.hget(
constants.CALL_MESSAGES_TEMPLATE % call_id, message_id
+1
View File
@@ -211,6 +211,7 @@ class Message(models.Model):
call: fields.ForeignKeyRelation["Call"] = fields.ForeignKeyField(
"models.Call", related_name="messages", on_delete=fields.OnDelete.CASCADE
)
call_id: int
channel: fields.ForeignKeyRelation["Channel"] = fields.ForeignKeyField(
"models.Channel", related_name="messages", on_delete=fields.OnDelete.CASCADE
)