Discord.js: Sending attachment with content sends ONLY attachment

Created on 10 Dec 2017  ·  3Comments  ·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:
While you sending a message with content and attachment, djs sends only the attachment without the content.

Include a reproducible code sample here, if possible:

await msg.channel.send("Here's your file", new MessageAttachment(Buffer.from(result), `${Date.now()}.txt`));

Further details:

  • discord.js version: latest from Github
  • node.js version: v9.2.1
  • Operating system: Linux 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux / Ubuntu 17.04 zesty

  • [ ] I found this issue while running code on a __user account__

  • [x] I have tested the issue on latest master, commit hash: 20689a51a1c37ff7b7edaff357621640d68bac67
medium REST bug

All 3 comments

Unless you import MessageAttachment as Attachment in your code (ala const { MessageAttachment: Attachment } = require("discord.js")), this works for me.
Make sure result isn't actually null or whatnot.

Oh hoh, I see what you mean now. The content isn't sent.
It works if you make it an object including content, and an array of files where you put in new Attachment

By the way, you forgot a $ in your template for the file name.

This does not look like D.js master as it's MessageAttachment, but I've tested the same code on master and can confirm the same issue. :thumbsup:

@Soumil07 ah, that's because the example code comes from my actual code, where I imported MessageAttachment as Attachment as because I'm lazy to change all the.. 1 reference using Ctrl+H 🤦‍♂️
Anyway, fixed. As well as the wrong filename mentioned by @KingDGrizzle. 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Lombra picture Lombra  ·  3Comments

shukriadams picture shukriadams  ·  3Comments

LLamaFTL picture LLamaFTL  ·  3Comments

iCrawl picture iCrawl  ·  3Comments

Blumlaut picture Blumlaut  ·  3Comments