mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(discord): properly route slash event handling in threads
Cherry-picked from PR #2017 by @simpolism. Fixes #2011. Discord slash commands in threads were missing thread_id in the SessionSource, causing them to route to the parent channel session. Commands like /usage and /reset returned wrong data or affected the wrong session. Detects discord.Thread channels in _build_slash_event and sets chat_type='thread' with thread_id. Two tests added.
This commit is contained in:
parent
a9f9c60efd
commit
ffa8b562e9
2 changed files with 48 additions and 1 deletions
|
|
@ -1500,7 +1500,17 @@ class DiscordAdapter(BasePlatformAdapter):
|
|||
def _build_slash_event(self, interaction: discord.Interaction, text: str) -> MessageEvent:
|
||||
"""Build a MessageEvent from a Discord slash command interaction."""
|
||||
is_dm = isinstance(interaction.channel, discord.DMChannel)
|
||||
chat_type = "dm" if is_dm else "group"
|
||||
is_thread = isinstance(interaction.channel, discord.Thread)
|
||||
thread_id = None
|
||||
|
||||
if is_dm:
|
||||
chat_type = "dm"
|
||||
elif is_thread:
|
||||
chat_type = "thread"
|
||||
thread_id = str(interaction.channel_id)
|
||||
else:
|
||||
chat_type = "group"
|
||||
|
||||
chat_name = ""
|
||||
if not is_dm and hasattr(interaction.channel, "name"):
|
||||
chat_name = interaction.channel.name
|
||||
|
|
@ -1516,6 +1526,7 @@ class DiscordAdapter(BasePlatformAdapter):
|
|||
chat_type=chat_type,
|
||||
user_id=str(interaction.user.id),
|
||||
user_name=interaction.user.display_name,
|
||||
thread_id=thread_id,
|
||||
chat_topic=chat_topic,
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue