openclaw - 💡(How to fix) Fix [Bug]: Discord attachments sent via message tool do not arrive (buffer reports success, path inputs fail) [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#44555Fetched 2026-04-08 00:45:18
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Discord attachments sent through the OpenClaw message tool do not arrive correctly: buffer-based sends can report success without a visible attachment, while path-based sends fail.

Root Cause

Discord attachments sent through the OpenClaw message tool do not arrive correctly: buffer-based sends can report success without a visible attachment, while path-based sends fail.

RAW_BUFFERClick to expand / collapse

Bug type

Behavior bug (incorrect output/state without crash)

Summary

Discord attachments sent through the OpenClaw message tool do not arrive correctly: buffer-based sends can report success without a visible attachment, while path-based sends fail.

Steps to reproduce

  1. Configure a working Discord channel/account in OpenClaw.
  2. Confirm that plain text outbound messages to Discord succeed.
  3. Send an attachment through the message tool using a buffer payload:
  • provide buffer, filename, and mimeType
  1. Observe that the tool can report success / return a message id, but no actual attachment appears in Discord.
  2. Send an attachment through the message tool using a local file path:
  • media: file:///...
  • or path
  • or filePath
  1. Observe that path-based attachment sends fail.
  2. Optionally attempt to configure channels.discord.mediaLocalRoots on OpenClaw 2026.3.8 and observe that config validation rejects the key.

Expected behavior

Discord attachments sent through the message tool should arrive as real visible attachments in the Discord client for both supported buffer-based and path-based workflows.

Actual behavior

Buffer-based attachment sends can report success, but no visible attachment appears in Discord. Path-based attachment sends fail. The issue reproduces with multiple file types, including TXT, PNG, and PDF.

OpenClaw version

OpenClaw version: 2026.3.8

Operating system

Host OS: Linux Ubuntu24

Install method

No response

Model

openai-codex/gpt5.4

Provider / routing chain

openclaw->codex auth->codex/gpt5.4

Config file / key location

No response

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

No response

extent analysis

Fix Plan

To resolve the issue with Discord attachments not arriving correctly, we need to update the attachment handling logic in the OpenClaw message tool.

Buffer-Based Sends

For buffer-based sends, we need to ensure that the buffer, filename, and mimeType are correctly formatted and sent to the Discord API.

  • Update the sendAttachment function to include the filename and mimeType in the API request:
const sendAttachment = async (buffer, filename, mimeType) => {
  const formData = new FormData();
  formData.append('file', buffer, filename);
  formData.append('filename', filename);
  formData.append('mimeType', mimeType);

  const response = await fetch('https://discord.com/api/v9/channels/${channelId}/messages', {
    method: 'POST',
    body: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });

  return response.json();
};

Path-Based Sends

For path-based sends, we need to update the sendAttachment function to handle file paths correctly.

  • Update the sendAttachment function to read the file from the local file system and send it to the Discord API:
const fs = require('fs');
const path = require('path');

const sendAttachment = async (filePath) => {
  const fileBuffer = fs.readFileSync(filePath);
  const filename = path.basename(filePath);
  const mimeType = getMimeType(filename);

  const formData = new FormData();
  formData.append('file', fileBuffer, filename);
  formData.append('filename', filename);
  formData.append('mimeType', mimeType);

  const response = await fetch('https://discord.com/api/v9/channels/${channelId}/messages', {
    method: 'POST',
    body: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });

  return response.json();
};

const getMimeType = (filename) => {
  const mimeTypes = {
    'txt': 'text/plain',
    'png': 'image/png',
    'pdf': 'application/pdf',
  };

  const extension = path.extname(filename);
  return mimeTypes[extension.slice(1)];
};

Verification

To verify that the fix worked, send an attachment through the message tool using both buffer-based and path-based workflows and check that the attachment appears in the Discord client.

Extra Tips

  • Ensure that the channels.discord.mediaLocalRoots configuration key is correctly set to allow path-based sends.
  • Handle errors and exceptions properly to prevent crashes and provide useful error messages.
  • Test the fix with different file types and sizes to ensure that it works correctly in all scenarios.

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 attachments sent through the message tool should arrive as real visible attachments in the Discord client for both supported buffer-based and path-based workflows.

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 [Bug]: Discord attachments sent via message tool do not arrive (buffer reports success, path inputs fail) [1 participants]