fix(shard): 🐛 Fix not found in on_message() when replying to a bot within the same channel.

This commit is contained in:
2025-03-16 11:09:29 -03:00
parent c4df5a31e7
commit ec3142f606
+45 -31
View File
@@ -285,40 +285,50 @@ class Calls(base.Cog):
original_message_id is not None
and original_message_id != replied_message.id
):
replied_message = await self.bot.get_partial_messageable(
other_channel
).fetch_message(original_message_id)
try:
replied_message = await self.bot.get_partial_messageable(
other_channel
).fetch_message(original_message_id)
replied_message_content = self.bot.clean_message(replied_message)
replied_participant = await call.get_participant(
replied_message.author.id
)
except discord.errors.NotFound:
replied_message = None
if replied_participant is None:
message_content += (
"\n-# ⓘ In reply to a message from outside this call."
if replied_message is not None:
replied_message_content = self.bot.clean_message(replied_message)
replied_participant = await call.get_participant(
replied_message.author.id
)
else:
embeds.append(
discord.Embed(
color=constants.PRIMARY_COLOR,
description=replied_message_content,
author=discord.EmbedAuthor(
name=(
replied_participant.display_name
if replied_participant.channel_id
== message.channel.id
else replied_participant.name
),
icon_url=(
replied_participant.display_avatar_url
if replied_participant.channel_id
== message.channel.id
else replied_participant.avatar_url
),
),
if replied_participant is None:
message_content += (
"\n-# ⓘ In reply to a message from outside this call."
)
else:
embeds.append(
discord.Embed(
color=constants.PRIMARY_COLOR,
description=replied_message_content,
author=discord.EmbedAuthor(
name=(
replied_participant.display_name
if replied_participant.channel_id
== message.channel.id
else replied_participant.name
),
icon_url=(
replied_participant.display_avatar_url
if replied_participant.channel_id
== message.channel.id
else replied_participant.avatar_url
),
),
)
)
else:
message_content += (
"\n-# ⓘ In reply to a message from outside this call."
)
else:
@@ -367,7 +377,9 @@ class Calls(base.Cog):
for _ in range(3):
try:
webhook = discord.Webhook.from_url(
await self.bot.call_handler.get_channel_webhook_url(other_channel),
await self.bot.call_handler.get_channel_webhook_url(
other_channel
),
session=session,
bot_token=constants.TOKEN,
)
@@ -390,7 +402,9 @@ class Calls(base.Cog):
break
except discord.errors.DiscordException:
await self.bot.call_handler.refresh_channel_webhook_url(other_channel)
await self.bot.call_handler.refresh_channel_webhook_url(
other_channel
)
@commands.Cog.listener()
async def on_raw_message_delete(