Skip to content

feat(discord): route GUILD_MEMBER_ADD events to agents #23978

@pdd-cli

Description

@pdd-cli

Summary

OpenClaw does not currently route Discord GUILD_MEMBER_ADD (member join) events to agents. The only workaround is polling via a cron job that calls the Discord REST API with curl, which is unreliable — agents receive join notifications minutes or days late, and the approach leaks the bot token into process arguments.

Current behavior

  • No DiscordMemberAddListener exists in src/discord/monitor/listeners.ts
  • Agents that need to react to member joins (e.g. welcome bots) must poll Discord's REST API on a cron schedule
  • The guildMembers privileged intent config key exists (channels.discord.intents.guildMembers) but enabling it has no effect — nothing consumes GUILD_MEMBER_ADD events from the gateway

Expected behavior

When a user joins a Discord guild, the event is routed to the appropriate agent (via the existing binding/routing system) as a system event, the same way reactions and presence updates are handled today.

What's already in place

  • @buape/carbon exposes GuildMemberAddListener (and GuildMemberRemoveListener, GuildMemberUpdateListener) ready to extend
  • src/discord/monitor/gateway-plugin.ts already gates on intentsConfig?.guildMembers to set GatewayIntents.GuildMembers
  • resolveAgentRoute() already accepts guildId and memberRoleIds — no routing changes needed
  • enqueueSystemEvent() is the established pattern for delivering non-message events to agent sessions (see reaction listener at src/discord/monitor/listeners.ts)

Proposed implementation

  1. Add DiscordMemberAddListener class in src/discord/monitor/listeners.ts extending GuildMemberAddListener
  2. In the handler: extract guild ID + user ID + member roles, call resolveAgentRoute(), format a human-readable event text, queue via enqueueSystemEvent()
  3. Register the listener in monitorDiscordProvider() (currently src/discord/monitor/provider.ts ~line 554)
  4. Update docs (docs/channels/discord.md) to document the intents.guildMembers config key and member event routing

Labels

feature, discord

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions