Send mp4 file

I have a mp4 in my directory that I want to send it but it's sending the video like this. how can I fix this
message.channel.send({files : [mp4finalPath]});
message.channel.send({files : [mp4finalPath]});
No description
10 Replies
d.js toolkit
d.js toolkit2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Syjalo
Syjalo2y ago
Your file is empty
theopenroad
theopenroadOP2y ago
No description
theopenroad
theopenroadOP2y ago
It's not anymore
Adidi
Adidi2y ago
@Tor you need to convert that to a link if to does not work upload to youtube or medal
theopenroad
theopenroadOP2y ago
Someone tell me you must attach it how can I do that ?
Adidi
Adidi2y ago
i think you need to switch the files in the reply to attachments
/home/exefer
/home/exefer2y ago
You want to read the file with fs and get the buffer from it Sorry if i didnt answer previously, here's a snippet that does the job:
import { AttachmentBuilder } from "discord.js"
import fs from "fs"

// ... other code

const myvideo = fs.readFileSync('/path/to/my/video.mp4');
message.channel.send({ content: "Here's the video:", files: [new AttachmentBuilder(myvideo, { name: 'video.mp4' })] });

// ...
import { AttachmentBuilder } from "discord.js"
import fs from "fs"

// ... other code

const myvideo = fs.readFileSync('/path/to/my/video.mp4');
message.channel.send({ content: "Here's the video:", files: [new AttachmentBuilder(myvideo, { name: 'video.mp4' })] });

// ...
@Tor
theopenroad
theopenroadOP2y ago
Thanks G Thank you Your methods were working
vulpz
vulpz2y ago
This worked yesterday but now it throws UND_ERR_ABORTED. Any chance it's related to the API issues today? ok guess I'll wait till tomorrow to check it, thnx

Did you find this page helpful?