openclaw - 💡(How to fix) Fix Bug: Discord message delete works in guild channels but fails in DMs [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#55048Fetched 2026-04-08 01:33:14
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

OpenClaw can delete bot-authored messages in Discord guild channels, but the same message delete action fails in Discord DMs.

Observed errors:

  • Cannot execute action on a DM channel
  • sometimes guildId required

This looks like a DM-specific routing/guard bug in OpenClaw’s Discord message-action layer, not a Discord API limitation.


Root Cause

OpenClaw can delete bot-authored messages in Discord guild channels, but the same message delete action fails in Discord DMs.

Observed errors:

  • Cannot execute action on a DM channel
  • sometimes guildId required

This looks like a DM-specific routing/guard bug in OpenClaw’s Discord message-action layer, not a Discord API limitation.


Fix Action

Fix / Workaround

The issue appears to be in the higher-level Discord message-action dispatch / validation layer, where DM delete is being incorrectly treated as guild-scoped.

So the failing guard appears to be upstream or in a different active dispatch path.

  • OpenClaw: local install
  • Surface: Discord
  • DM delete fails
  • Guild delete succeeds
  • No local patch remained in place after rollback during diagnosis

Code Example

Cannot execute action on a DM channel

---

guildId required

---

{
  "action": "delete",
  "channel": "discord",
  "channelId": "channel:<dm-channel-id>",
  "messageId": "<bot-message-id>"
}

---

Cannot execute action on a DM channel

---

DELETE /channels/{channel.id}/messages/{message.id}

---

async function deleteMessageDiscord(channelId, messageId, opts = {}) {
  await resolveDiscordRest(opts).delete(Routes.channelMessage(channelId, messageId));
  return { ok: true };
}

---

async function deleteMessageDiscord(channelId, messageId, opts = {}) {
  await resolveDiscordRest(opts).delete(Routes.channelMessage(channelId, messageId));
  return { ok: true };
}

---

if (action === "delete") {
  const messageId = readStringParam(params, "messageId", { required: true });
  return await handleDiscordAction({
    action: "deleteMessage",
    accountId: accountId ?? void 0,
    channelId: resolveChannelId(),
    messageId
  }, cfg, actionOptions);
}

---

Cannot execute action on a DM channel
RAW_BUFFERClick to expand / collapse

Bug: Discord message delete works in guild channels but fails in DMs

Summary

OpenClaw can delete bot-authored messages in Discord guild channels, but the same message delete action fails in Discord DMs.

Observed errors:

  • Cannot execute action on a DM channel
  • sometimes guildId required

This looks like a DM-specific routing/guard bug in OpenClaw’s Discord message-action layer, not a Discord API limitation.


Expected behavior

Discord message delete should be able to delete a bot-authored message in:

  • guild channels / threads
  • DM channels

as long as the bot is deleting its own message and has normal API access to that channel.


Actual behavior

Guild channels

Deletion succeeds.

Discord DMs

Deletion fails with:

Cannot execute action on a DM channel

And in some diagnostic attempts:

guildId required

Reproduction

Using the message tool / equivalent CLI action:

{
  "action": "delete",
  "channel": "discord",
  "channelId": "channel:<dm-channel-id>",
  "messageId": "<bot-message-id>"
}

Result

In a Discord DM:

Cannot execute action on a DM channel

In a guild channel:

  • same deletion flow works

Why this appears to be an OpenClaw bug

1. Docs indicate Discord delete is supported

Local docs for openclaw message list:

  • delete
  • Channels: Discord/Slack/Telegram
  • Required: --message-id, --target

No note was found saying Discord delete is guild-only or unsupported in DMs.

2. Discord channel docs describe Discord as supporting DMs and guild channels

Local docs say Discord is ready for:

  • DMs
  • guild channels

3. Discord API itself supports deleting bot-authored messages in DMs

The low-level Discord REST path is the standard channel message delete route:

DELETE /channels/{channel.id}/messages/{message.id}

In the built OpenClaw runtime, the low-level delete function is:

async function deleteMessageDiscord(channelId, messageId, opts = {}) {
  await resolveDiscordRest(opts).delete(Routes.channelMessage(channelId, messageId));
  return { ok: true };
}

This function is not guild-specific.

4. Guild deletion works

This rules out:

  • Discord deletion being globally broken
  • token/auth being generally invalid
  • delete capability being disabled everywhere

The failure is specifically DM-context-sensitive.


Likely fault area

The issue appears to be in the higher-level Discord message-action dispatch / validation layer, where DM delete is being incorrectly treated as guild-scoped.

Likely possibilities:

  1. Discord delete is routed through a guild-only path in DM context.
  2. A DM guard rejects the action before it reaches deleteMessageDiscord(...).
  3. Provider/action resolution incorrectly classifies delete as requiring guild context.

Diagnostic notes

From local inspection of the built runtime:

Low-level delete exists and looks fine:

async function deleteMessageDiscord(channelId, messageId, opts = {}) {
  await resolveDiscordRest(opts).delete(Routes.channelMessage(channelId, messageId));
  return { ok: true };
}

A Discord message-action handler also maps delete to deleteMessage at one layer:

if (action === "delete") {
  const messageId = readStringParam(params, "messageId", { required: true });
  return await handleDiscordAction({
    action: "deleteMessage",
    accountId: accountId ?? void 0,
    channelId: resolveChannelId(),
    messageId
  }, cfg, actionOptions);
}

Despite that, the live tool call in a DM still returns:

Cannot execute action on a DM channel

So the failing guard appears to be upstream or in a different active dispatch path.


Suggested acceptance test

  1. Send a bot-authored message in a Discord DM.
  2. Call message delete with the DM channelId and that messageId.
  3. Expect success.
  4. Verify guild channel deletion still works.

Environment

  • OpenClaw: local install
  • Surface: Discord
  • DM delete fails
  • Guild delete succeeds
  • No local patch remained in place after rollback during diagnosis

extent analysis

Fix Plan

To fix the issue of Discord message delete failing in DMs, we need to update the Discord message-action dispatch layer to correctly handle DM delete actions.

Here are the steps:

  • Update the handleDiscordAction function to remove the guild-only check for deleteMessage actions.
  • Modify the resolveChannelId function to correctly resolve DM channel IDs.
  • Add a check to ensure the bot has permission to delete messages in the DM channel.

Example code changes:

// Update handleDiscordAction to remove guild-only check
if (action === "delete") {
  const messageId = readStringParam(params, "messageId", { required: true });
  return await handleDiscordAction({
    action: "deleteMessage",
    accountId: accountId ?? void 0,
    channelId: resolveChannelId(), // Update resolveChannelId to handle DMs
    messageId
  }, cfg, actionOptions);
}

// Update resolveChannelId to handle DMs
function resolveChannelId() {
  if (isDMChannel()) {
    return getDMChannelId();
  } else {
    return getGuildChannelId();
  }
}

// Add permission check for DM channels
async function deleteMessageDiscord(channelId, messageId, opts = {}) {
  if (isDMChannel(channelId)) {
    if (!hasPermissionToDeleteInDM(channelId)) {
      throw new Error("Cannot delete message in DM channel");
    }
  }
  await resolveDiscordRest(opts).delete(Routes.channelMessage(channelId, messageId));
  return { ok: true };
}

Verification

To verify the fix, run the suggested acceptance test:

  1. Send a bot-authored message in a Discord DM.
  2. Call message delete with the DM channelId and that messageId.
  3. Expect success.
  4. Verify guild channel deletion still works.

Extra Tips

  • Ensure the bot has the necessary permissions to delete messages in DM channels.
  • Test the fix in different environments to ensure it works consistently.
  • Consider adding additional logging or error handling to help diagnose any future issues.

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…

FAQ

Expected behavior

Discord message delete should be able to delete a bot-authored message in:

  • guild channels / threads
  • DM channels

as long as the bot is deleting its own message and has normal API access to that channel.


Still need to ship something?

×6

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

Back to top recommendations

TRENDING