Discord Embed - "Not well formed URL"

So I’m trying to put an image as thumbnail in a DiscordEmbed in Node.js. The problem is, that the image loads forever and will ultimately not be displayed. The url in question is
https://static-cdn.jtvnw.net/ttv-boxart/./Oddworld:%20Abe%27s%20Oddysee-140x180.jpg
and the code to set the thumbnail is:

    const embeded = new Discord.MessageEmbed();
    embeded.setThumbnail(url);

I’ve tried other urls like:

  • urls without spaces in the filename (which work)
  • urls with only spaces and no other special characters in the filename (which work)
  • urls with apostrophys only in the filename (which doesn’t work)
  • urls with a colon only (which doesn’t work)

Trying to escape/encode the url in the filename part didn’t work. I tried encodeURI(url) as well as encodeURIComponent(url) and also replacing the colon or apostrophy manually with url.replace(/'/g, '%23') for example. I’m at my wits end here :frowning:

Odd, the program might not like all the special characters in the url. Does the image have to be loaded from Twitch’s CDN? Could you try uploading it to your own project or uploading it to a service like file.coffee?

I have uploaded the image again to https://imgur.com/a/25G6pjX, so no apostrophys, colons or other special characters. Interestingly, the image still cannot be put into the embed :confused:

Have you put speech marks around the link

Yes. I tried the following:

const embeded = {
	thumbnail: {
		url: "https://static-cdn.jtvnw.net/ttv-boxart/./Oddworld:%20Abe%27s%20Oddysee-140x180.jpg"
	}
};
const boxart_url = "https://imgur.com/a/25G6pjX.jpg";
const embeded = new Discord.MessageEmbed();
embeded.setThumbnail("\"" + boxart_url + "\""); // not working
/*   */
embeded.setThumbnail(boxart_url); // also not working

This applies to the original url as well

embeded.setThumbnail('https://imgur.com/a/25G6pjX.jpg')

Thats why it isn’t a “well formed URL”.

I don’t seem to get, why single quotes could make a difference here.

const embeded = new Discord.MessageEmbed();
embeded.setThumbnail('https://www.imgur.com/a/25G6pjX.jpg');
message.channel.send({embed: embeded});

Nothing changed unfortunately :confused: https://imgur.com/a/3yzzNcM

Because the image is might be removed. Anyway try with
message.channel.send(embeded).

This didn’t work. But I’ve found a solution… kinda. I can use attachments to display the image there. It just requires me to download and save the image locally beforehand. It’s not really what I wanted to have but as long as it works… :smiley:
Here’s the code if anybody has the same problem:

const request = require('request'); //depricated !
const fs = require('fs');
const directory = "../data/images/boxart/";

var download = function(url, filename, callback){
    request.head(url, function(err, res, body){
        request(url).pipe(fs.createWriteStream(filename)).on('close', callback);
    });
};

download('https://static-cdn.jtvnw.net/ttv-boxart/./Oddworld:%20Abe%27s%20Oddysee-70x99.jpg', directory + 'oddysee.jpg', function(){
    console.log('image downloaded');
});

let boxart_url = "data/images/boxart/oddysee.jpg"; // locally
const filename = boxart_url.substring( boxart_url.lastIndexOf('/') + 1 );

const file = new Discord.MessageAttachment(boxart_url);
const embeded = new Discord.MessageEmbed();
embeded.setThumbnail('attachment://'+filename);
message.channel.send({files: [file], embed: embeded});