fix(shard): 🐛 Fix not found in on_message() when replying to a bot within the same channel.
This commit is contained in:
+45
-31
@@ -285,40 +285,50 @@ class Calls(base.Cog):
|
|||||||
original_message_id is not None
|
original_message_id is not None
|
||||||
and original_message_id != replied_message.id
|
and original_message_id != replied_message.id
|
||||||
):
|
):
|
||||||
replied_message = await self.bot.get_partial_messageable(
|
try:
|
||||||
other_channel
|
replied_message = await self.bot.get_partial_messageable(
|
||||||
).fetch_message(original_message_id)
|
other_channel
|
||||||
|
).fetch_message(original_message_id)
|
||||||
|
|
||||||
replied_message_content = self.bot.clean_message(replied_message)
|
except discord.errors.NotFound:
|
||||||
replied_participant = await call.get_participant(
|
replied_message = None
|
||||||
replied_message.author.id
|
|
||||||
)
|
|
||||||
|
|
||||||
if replied_participant is None:
|
if replied_message is not None:
|
||||||
message_content += (
|
replied_message_content = self.bot.clean_message(replied_message)
|
||||||
"\n-# ⓘ In reply to a message from outside this call."
|
replied_participant = await call.get_participant(
|
||||||
|
replied_message.author.id
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
if replied_participant is None:
|
||||||
embeds.append(
|
message_content += (
|
||||||
discord.Embed(
|
"\n-# ⓘ In reply to a message from outside this call."
|
||||||
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:
|
||||||
|
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:
|
else:
|
||||||
@@ -367,7 +377,9 @@ class Calls(base.Cog):
|
|||||||
for _ in range(3):
|
for _ in range(3):
|
||||||
try:
|
try:
|
||||||
webhook = discord.Webhook.from_url(
|
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,
|
session=session,
|
||||||
bot_token=constants.TOKEN,
|
bot_token=constants.TOKEN,
|
||||||
)
|
)
|
||||||
@@ -390,7 +402,9 @@ class Calls(base.Cog):
|
|||||||
break
|
break
|
||||||
|
|
||||||
except discord.errors.DiscordException:
|
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()
|
@commands.Cog.listener()
|
||||||
async def on_raw_message_delete(
|
async def on_raw_message_delete(
|
||||||
|
|||||||
Reference in New Issue
Block a user