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:
曾文锋0668000834 2026-03-13 09:17:35 +08:00
parent 19835b2f60
commit 17eeb35da6

View file

@ -451,12 +451,19 @@ func (c *DiscordChannel) handleMessage(s *discordgo.Session, m *discordgo.Messag
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{
"user_id": senderID,
"username": m.Author.Username,
"display_name": sender.DisplayName,
"guild_id": m.GuildID,
"channel_id": m.ChannelID,
"channel_name": channelName,
"is_dm": fmt.Sprintf("%t", m.GuildID == ""),
}