feat(discord): include channel name in message metadata
Add Discord channel name to metadata map when processing messages. This provides better context for the agent by including the human-readable channel name alongside the numeric channel ID. The channel name is retrieved from Discord's state cache (zero-cost lookup in common case) with graceful handling if not available. Fixes #1451
This commit is contained in:
parent
19835b2f60
commit
17eeb35da6
1 changed files with 7 additions and 0 deletions
|
|
@ -451,12 +451,19 @@ func (c *DiscordChannel) handleMessage(s *discordgo.Session, m *discordgo.Messag
|
||||||
|
|
||||||
peer := bus.Peer{Kind: peerKind, ID: peerID}
|
peer := bus.Peer{Kind: peerKind, ID: peerID}
|
||||||
|
|
||||||
|
// Get channel name from Discord state (with API fallback on cache miss)
|
||||||
|
channelName := ""
|
||||||
|
if channel, err := c.session.State.Channel(m.ChannelID); err == nil && channel != nil {
|
||||||
|
channelName = channel.Name
|
||||||
|
}
|
||||||
|
|
||||||
metadata := map[string]string{
|
metadata := map[string]string{
|
||||||
"user_id": senderID,
|
"user_id": senderID,
|
||||||
"username": m.Author.Username,
|
"username": m.Author.Username,
|
||||||
"display_name": sender.DisplayName,
|
"display_name": sender.DisplayName,
|
||||||
"guild_id": m.GuildID,
|
"guild_id": m.GuildID,
|
||||||
"channel_id": m.ChannelID,
|
"channel_id": m.ChannelID,
|
||||||
|
"channel_name": channelName,
|
||||||
"is_dm": fmt.Sprintf("%t", m.GuildID == ""),
|
"is_dm": fmt.Sprintf("%t", m.GuildID == ""),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue