Send video as attachment from url

I'm trying to send a video as an attachment but I'm getting an error
{
url: 'https://cdn.discordapp.com/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4?ex=655a467e&is=6547d17e&hm=c2646af1ffc78e9d4e880e179582d5f2b9f0b8138bd5ed723cef8027789f98a2&',
proxyURL: 'https://media.discordapp.net/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4',
width: 480,
height: 854
}
{
url: 'https://cdn.discordapp.com/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4?ex=655a467e&is=6547d17e&hm=c2646af1ffc78e9d4e880e179582d5f2b9f0b8138bd5ed723cef8027789f98a2&',
proxyURL: 'https://media.discordapp.net/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4',
width: 480,
height: 854
}
TypeError: Cannot read properties of undefined (reading 'path')
TypeError: Cannot read properties of undefined (reading 'path')
What am I doing wrong? If I upload from my client itself I see an attachment object that looks like this
{
"contentType": "video/mp4",
"description": null,
"ephemeral": false,
"height": 854,
"id": "1171519663264505896",
"name": "395548916_313950368025649_163387286946890286_n.mp4",
"proxyURL": "https://media.discordapp.net/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"size": 596512,
"spoiler": false,
"url": "https://cdn.discordapp.com/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"width": 480
}
{
"contentType": "video/mp4",
"description": null,
"ephemeral": false,
"height": 854,
"id": "1171519663264505896",
"name": "395548916_313950368025649_163387286946890286_n.mp4",
"proxyURL": "https://media.discordapp.net/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"size": 596512,
"spoiler": false,
"url": "https://cdn.discordapp.com/attachments/1077725097936310452/1171519663264505896/395548916_313950368025649_163387286946890286_n.mp4?ex=655cf9b5&is=654a84b5&hm=6451e0b04d97fa63413c063e8d0110ee5032f72b8a82e7252859eea154ce120e&",
"width": 480
}
Which fields do I need to include?
6 Replies
d.js toolkit
d.js toolkit7mo 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! - Marked as resolved by OP
jr
jr7mo ago
[11.07.23 11:41:48] [error] TypeError: Cannot read properties of undefined (reading 'path')
at findName (/x/node_modules/discord.js/src/structures/MessagePayload.js:241:17)
at MessagePayload.resolveFile (/x/node_modules/discord.js/src/structures/MessagePayload.js:255:31)
at /x/node_modules/discord.js/src/structures/MessagePayload.js:223:85
at Array.map (<anonymous>)
at MessagePayload.resolveFiles (/x/node_modules/discord.js/src/structures/MessagePayload.js:223:56)
at ThreadChannel.send (/x/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:161:50)
[11.07.23 11:41:48] [error] TypeError: Cannot read properties of undefined (reading 'path')
at findName (/x/node_modules/discord.js/src/structures/MessagePayload.js:241:17)
at MessagePayload.resolveFile (/x/node_modules/discord.js/src/structures/MessagePayload.js:255:31)
at /x/node_modules/discord.js/src/structures/MessagePayload.js:223:85
at Array.map (<anonymous>)
at MessagePayload.resolveFiles (/x/node_modules/discord.js/src/structures/MessagePayload.js:223:56)
at ThreadChannel.send (/x/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:161:50)
if I try to include a content type and name I run into
[11.07.23 11:42:53] [error] TypeError: Cannot read properties of undefined (reading 'Symbol(Symbol.asyncIterator)')
at DataResolver.resolveFile (/x/node_modules/discord.js/src/util/DataResolver.js:117:24)
at MessagePayload.resolveFile (/x/node_modules/discord.js/src/structures/MessagePayload.js:258:54)
at /x/node_modules/discord.js/src/structures/MessagePayload.js:223:85
at Array.map (<anonymous>)
at MessagePayload.resolveFiles (/x/node_modules/discord.js/src/structures/MessagePayload.js:223:56)
at ThreadChannel.send (/x/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:161:50)
[11.07.23 11:42:53] [error] TypeError: Cannot read properties of undefined (reading 'Symbol(Symbol.asyncIterator)')
at DataResolver.resolveFile (/x/node_modules/discord.js/src/util/DataResolver.js:117:24)
at MessagePayload.resolveFile (/x/node_modules/discord.js/src/structures/MessagePayload.js:258:54)
at /x/node_modules/discord.js/src/structures/MessagePayload.js:223:85
at Array.map (<anonymous>)
at MessagePayload.resolveFiles (/x/node_modules/discord.js/src/structures/MessagePayload.js:223:56)
at ThreadChannel.send (/x/node_modules/discord.js/src/structures/interfaces/TextBasedChannel.js:161:50)
monbrey
monbrey7mo ago
Wheres your actual code? How exactly are you attempting to do this?
jr
jr7mo ago
The actual code is complex but it should reproduce with
channel.send({
files: [
{
url: 'https://cdn.discordapp.com/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4?ex=655a467e&is=6547d17e&hm=c2646af1ffc78e9d4e880e179582d5f2b9f0b8138bd5ed723cef8027789f98a2&',
proxyURL: 'https://media.discordapp.net/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4',
width: 480,
height: 854
}
]
});
channel.send({
files: [
{
url: 'https://cdn.discordapp.com/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4?ex=655a467e&is=6547d17e&hm=c2646af1ffc78e9d4e880e179582d5f2b9f0b8138bd5ed723cef8027789f98a2&',
proxyURL: 'https://media.discordapp.net/attachments/1070007323961085973/1170777477723979988/395548916_313950368025649_163387286946890286_n.mp4',
width: 480,
height: 854
}
]
});
monbrey
monbrey7mo ago
Well that isnt correct, you dont pass an object like that to files It can be an AttachmentBuilder, Attachment object you received, or { name: string, attachment: "the url would go here" } Or you could just pass the URL directly, but not that object proxyURL, width and height are just parameters discord sends you
jr
jr7mo ago
I see Ah that did indeed work Tysm 🙏