#Invalid Form Body embeds[0].image.url[URL_TYPE_INVALID_URL] Not a well formed URL?
36 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
my code: ```js
const e = user2.presence.activities
const duration = e[0].timestamps.end.getTime() - e[0].timestamps.start.getTime()
const f = String(e[0].assets.largeImage).slice(8)
const elapsed = Date.now() - e[0].timestamps.start.getTime()
const image = https://i.scdn.co/image/${String(e[0].assets.largeImage).slice(8)}
const URL = https://api.aniket091.xyz/spotifycard?name=${e[0].details}&artists=${e[0].state}&image=${image}&elapsedtime=${elapsed}&totaltime=${duration}&key=xyz
await fetch(URL).then((res) => console.log(res))
if (interaction.user.id === client.config.adminId) {
interaction.channel.send({
embeds: [
new EmbedBuilder()
.setImage(URL)
.setDescription( Details: ${e[0].details} Elapsed Time: ${formatDuration(Date.now() - e[0].timestamps.start.getTime())} Start Time: ${e[0].timestamps.start.getTime()} End Time: ${e[0].timestamps.end.getTime()} Duration: ${formatDuration(duration)} Album: ${e[0].assets.largeText} Author: ${e[0].state})
]
})
}
and when I visit the exact link (the res console logs it), everything is normal
node: 17.9.0
what is this exact link
https://api.aniket091.xyz/spotifycard?name=Hot%20N%20Cold&artists=Katy%20Perry&image=https://i.scdn.co/image/ab67616d0000b273df35c65d88dfacb5798f7291&elapsedtime=118256&totaltime=220226
ah
how shall i make it into a PNG?
because I really do want it in my .setImage() thing
You already fetched the file, make that into a Buffer, add it in an AttachmentBuilder and use that
alright, thanks a lot
@stuck flame so I made a few changes, I added:
const buffer = await fetch(URL)
const attachment = new AttachmentBuilder(buffer, {
name: "spotify.png",
})
and then
.setImage(attachment)
MessageEmbed#attachFiles has been removed. Files should be attached via the message option object instead:
const attachment = new MessageAttachment('./image.png', 'image1.png');
const embed = new MessageEmbed()
- .attachFiles([attachment])
.setTitle('Attachments')
.setImage(`attachment://${attachment.name}`);
- channel.send(embed)
+ channel.send({
+ embeds: [embed],
+ files: [attachment]
+ });
Ignore the v13 classes, but apart from that it‘s accurate
And attach the attachment in the files: when sending
yep
@stuck flame I did what you said but now its throwing another error smh
code for reference: ```js
if (interaction.user.id === client.config.adminId) {
const buffer = await fetch(URL)
const attachment = new AttachmentBuilder(buffer, {
name: "spotify.png",
})
interaction.channel.send({
embeds: [
new EmbedBuilder()
.setImage(attachment://${attachment.name})
.setDescription( Details: ${e[0].details} Elapsed Time: ${formatDuration(Date.now() - e[0].timestamps.start.getTime())} Start Time: ${e[0].timestamps.start.getTime()} End Time: ${e[0].timestamps.end.getTime()} Duration: ${formatDuration(duration)} Album: ${e[0].assets.largeText} Author: ${e[0].state})
],
files: [attachment]
})
}
Because the result from fetch is not a Buffer. Just because you call your variable buffer doesn’t make it one
hmm, how do I make it into a buffer?
im sorry this is my first time working with attachment builders
Depends on what fetch is here… is it node‘s own fetch? Is it an external package? Either of those should have documentation telling you how
nevermind