how do you check if an embed image have a validworking link?

You could check the args[0] content with a regex matcher, and if it doesn’t match an URI pattern you could throw an error.

const exampleEmbed = new Discord.MessageEmbed();
exampleEmbed.addField('Its a title!', 'Its a value!');
try {

    if (!(/https?:\/\/(www\.)?[[email protected]:%._\+~#=]{2,256}\.[a-z]{2,4}\b([[email protected]:%_\+.~#?&//=]*)/g).test(args[0])) {
        throw new Error(`Invalid URL`);
catch (error) { 

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top