fix(bot): 🐛 Message deletes not working.
This commit is contained in:
@@ -887,21 +887,21 @@ class Calls(base.Cog):
|
|||||||
message_id = payload.message_id
|
message_id = payload.message_id
|
||||||
channel_id = payload.channel_id
|
channel_id = payload.channel_id
|
||||||
|
|
||||||
is_on_call = await redis.sismember(
|
channel = await models.Channel.get(id=channel_id)
|
||||||
constants.CHANNELS_ONCALL_SET, str(channel_id)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not is_on_call:
|
if channel.call_id is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
message = await models.Message.get_or_none(id=message_id).select_related(
|
message_json = await redis.hget(
|
||||||
"propagation_channel"
|
constants.CALL_MESSAGES_TEMPLATE % channel.call_id, message_id
|
||||||
)
|
)
|
||||||
|
|
||||||
if message is None:
|
if message_json is None:
|
||||||
return
|
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:
|
if other_channel.call_id != message.call_id:
|
||||||
return
|
return
|
||||||
@@ -916,18 +916,6 @@ class Calls(base.Cog):
|
|||||||
# This message was already deleted.
|
# This message was already deleted.
|
||||||
pass
|
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.Cog.listener()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
@transactions.atomic()
|
@transactions.atomic()
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ async def ReplyEmbed(
|
|||||||
reference.message_id,
|
reference.message_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
print(constants.CALL_MESSAGE_FROM_PROPAGATION_TEMPLATE % call_id)
|
|
||||||
|
|
||||||
if message_id is not None:
|
if message_id is not None:
|
||||||
unflushed_message = await redis.hget(
|
unflushed_message = await redis.hget(
|
||||||
constants.CALL_MESSAGES_TEMPLATE % call_id, message_id
|
constants.CALL_MESSAGES_TEMPLATE % call_id, message_id
|
||||||
|
|||||||
@@ -211,6 +211,7 @@ class Message(models.Model):
|
|||||||
call: fields.ForeignKeyRelation["Call"] = fields.ForeignKeyField(
|
call: fields.ForeignKeyRelation["Call"] = fields.ForeignKeyField(
|
||||||
"models.Call", related_name="messages", on_delete=fields.OnDelete.CASCADE
|
"models.Call", related_name="messages", on_delete=fields.OnDelete.CASCADE
|
||||||
)
|
)
|
||||||
|
call_id: int
|
||||||
channel: fields.ForeignKeyRelation["Channel"] = fields.ForeignKeyField(
|
channel: fields.ForeignKeyRelation["Channel"] = fields.ForeignKeyField(
|
||||||
"models.Channel", related_name="messages", on_delete=fields.OnDelete.CASCADE
|
"models.Channel", related_name="messages", on_delete=fields.OnDelete.CASCADE
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user