fix(discord): drop invalid reply references

This commit is contained in:
LeonSGP43
2026-04-17 11:00:21 +08:00
committed by Teknium
parent 0231f8882b
commit a448e7a04d
2 changed files with 56 additions and 6 deletions

View File

@@ -873,7 +873,10 @@ class DiscordAdapter(BasePlatformAdapter):
if reply_to and self._reply_to_mode != "off":
try:
ref_msg = await channel.fetch_message(int(reply_to))
reference = ref_msg
if hasattr(ref_msg, "to_reference"):
reference = ref_msg.to_reference(fail_if_not_exists=False)
else:
reference = ref_msg
except Exception as e:
logger.debug("Could not fetch reply-to message: %s", e)
@@ -891,14 +894,20 @@ class DiscordAdapter(BasePlatformAdapter):
err_text = str(e)
if (
chunk_reference is not None
and "error code: 50035" in err_text
and "Cannot reply to a system message" in err_text
and (
(
"error code: 50035" in err_text
and "Cannot reply to a system message" in err_text
)
or "error code: 10008" in err_text
)
):
logger.warning(
"[%s] Reply target %s is a Discord system message; retrying send without reply reference",
"[%s] Reply target %s rejected the reply reference; retrying send without reply reference",
self.name,
reply_to,
)
reference = None
msg = await channel.send(
content=chunk,
reference=None,