openclaw - 💡(How to fix) Fix Discord: Support messageUpdate and messageDelete events for edit-to-reprocess and delete-to-cancel [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#53654Fetched 2026-04-08 01:25:16
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Add support for Discord messageUpdate and messageDelete gateway events so that:

  1. Edited messages re-trigger agent processing (if the edited message contains a bot mention)
  2. Deleted messages halt/abort the in-progress agent session that was triggered by that message

Root Cause

Add support for Discord messageUpdate and messageDelete gateway events so that:

  1. Edited messages re-trigger agent processing (if the edited message contains a bot mention)
  2. Deleted messages halt/abort the in-progress agent session that was triggered by that message

Fix Action

Fix / Workaround

Message Edit (messageUpdate)

  • If the edited message contains a bot mention and is mapped to an active or recent session:
    • If the session is still running: abort the current run and re-dispatch with the new content
    • If the session has completed: start a new session with the updated content
  • If the edited message does NOT contain a bot mention: ignore (same as current)
RAW_BUFFERClick to expand / collapse

Feature Request

Submitted by: Kat Arbiz ([email protected])

Summary

Add support for Discord messageUpdate and messageDelete gateway events so that:

  1. Edited messages re-trigger agent processing (if the edited message contains a bot mention)
  2. Deleted messages halt/abort the in-progress agent session that was triggered by that message

Use Case

Running a multi-agent AI operating system via Discord as the primary chat interface. When I send a command to my bot and realize I made a mistake:

  • Current behavior: I have to send a new "cancel" message and then re-send the corrected command. The original (wrong) command continues executing.
  • Desired behavior: I edit the original message → the agent picks up the updated content. Or I delete the message → the running agent session is aborted.

Proposed Behavior

Message Edit (messageUpdate)

  • If the edited message contains a bot mention and is mapped to an active or recent session:
    • If the session is still running: abort the current run and re-dispatch with the new content
    • If the session has completed: start a new session with the updated content
  • If the edited message does NOT contain a bot mention: ignore (same as current)

Message Delete (messageDelete)

  • If the deleted message is mapped to an active session:
    • Send an abort signal to the running agent session
    • Optionally post a status message: "Command cancelled (message deleted)"
  • If the session has already completed: no action needed

Technical Notes

  • The Discord extension uses @buape/carbon — event listeners would need to be added for messageUpdate and messageDelete
  • Requires a mapping from Discord message IDs to OpenClaw session IDs (may already exist in session key normalization)
  • The abort mechanism exists (abortSignal is already used in channel.ts:626)
  • Relevant files: extensions/discord/src/channel.ts, extensions/discord/src/monitor.ts, session management layer

Impact

This would make Discord a more natural and responsive interface for agent-driven workflows, especially for operators who use Discord as their primary command center.

Environment

  • OpenClaw version: 2026.3.23
  • Discord extension: bundled
  • Node.js: 25.1.0
  • macOS

extent analysis

Fix Plan

To add support for Discord messageUpdate and messageDelete gateway events, follow these steps:

  • Add event listeners for messageUpdate and messageDelete in extensions/discord/src/monitor.ts:
import { Client, Events } from 'discord.js';

// ...

client.on(Events.MessageUpdate, (oldMessage, newMessage) => {
  // Check if the edited message contains a bot mention
  if (newMessage.content.includes(`<@${client.user.id}>`)) {
    // Get the session ID from the message ID mapping
    const sessionId = getSessionIdFromMessageId(newMessage.id);
    // Abort the current run and re-dispatch with the new content
    abortSession(sessionId);
    dispatchSession(newMessage.content, sessionId);
  }
});

client.on(Events.MessageDelete, (message) => {
  // Get the session ID from the message ID mapping
  const sessionId = getSessionIdFromMessageId(message.id);
  // Send an abort signal to the running agent session
  abortSession(sessionId);
  // Optionally post a status message
  message.channel.send('Command cancelled (message deleted)');
});
  • Create a function to get the session ID from the message ID mapping:
const messageSessionMap = new Map();

function getSessionIdFromMessageId(messageId) {
  // Implement the logic to get the session ID from the message ID mapping
  // ...
  return sessionId;
}

function abortSession(sessionId) {
  // Implement the logic to abort the session
  // ...
}
  • Update the channel.ts file to include the abort mechanism:
// ...

async function dispatchSession(content, sessionId) {
  // ...
  try {
    // ...
  } catch (error) {
    // ...
  } finally {
    // Abort the session if it's still running
    if (abortSignal.aborted) {
      abortSession(sessionId);
    }
  }
}

Verification

To verify that the fix worked, test the following scenarios:

  • Edit a message that contains a bot mention and verify that the agent picks up the updated content.
  • Delete a message that is mapped to an active session and verify that the running agent session is aborted.
  • Verify that the abort mechanism works correctly by checking the session logs and the Discord channel for the status message.

Extra Tips

  • Make sure to handle errors and edge cases properly, such as when the message ID mapping is not found or when the session is already completed.
  • Consider adding logging and monitoring to track the performance and reliability of the Discord extension.
  • Review the code changes and test them thoroughly to ensure that they do not introduce any regressions or security vulnerabilities.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Discord: Support messageUpdate and messageDelete events for edit-to-reprocess and delete-to-cancel [1 participants]