I have setted the image for the embed message, and when I use command, it doesn’t send the message and errors:
9:36 PM
embed.image.url: Not a well formed URL.
9:36 PM
at item.request.gen.end (/rbd/pnpm-volume/bb4a590d-fd8f-4c98-b899-7f1655d4cceb/node_modules/.registry.npmjs.org/discord.js/11.5.1/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:85:15)
9:36 PM
at then (/rbd/pnpm-volume/bb4a590d-fd8f-4c98-b899-7f1655d4cceb/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)
9:36 PM
at <anonymous>
9:36 PM
at process._tickCallback (internal/process/next_tick.js:189:7)
9:36 PM
(node:20524) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)```
How can I fix this?
if (!biography) Profile.setImage ('https://dummyimage.com/2000x500/2f2f2f/ffffff&text=This user has not a bio.')
if (biography) Profile.setImage (`https://dummyimage.com/2000x500/2f2f2f/ffffff&text=${biography}`)
Muhtemelen ${biography} olarak tanımladığın şey tanımsızdır diye düşünüyorum.
Yukarıdaki arkadaşların yazdığı gibi sonuna .png eklersen de çözme ihtimalin var
Aldığın hata: embed.image.url: Not a well formed URL.
İyi düzenlenmemiş bir URL anlamına geliyor.
Yani sonuna .png .jpg şeklinde bir uzantı eklemen lazım diye tahmin ediyorum.
I believe your problem is that Discord.js first validates the URL. So if the URL has spaces in it it throws the Invalid Form Body error.
You probably need to encode the ${biography} part. You can do this using encodeURIComponent
Here’s a fix for your code:
if (!biography) Profile.setImage ('https://dummyimage.com/2000x500/2f2f2f/ffffff&text=This%20user%20has%20not%20a%20bio.')
if (biography) Profile.setImage (`https://dummyimage.com/2000x500/2f2f2f/ffffff&text=${encodeURIComponent(biography)}`)