Sending an image without the link showing with discord library

Julian L picture Julian L · Apr 3, 2018 · Viewed 12.2k times · Source

I would like my discord bot to send an image (from a url), but have the url be hidden from the message that is sent in chat. For sending messages, im using a switch statement that only uses the writing after an "!"

            case 'happy':
            bot.sendMessage({
                to: channelID,
                message: 'https://pictureexample.jpg'
            });

How would I send messages without having the link show in chat?

Answer

lil buda picture lil buda · Apr 26, 2018

As user4261590 wrote, you can use embeds to achieve this. Here's an example that might work for you:

case 'happy':
    const embed = {
        "image": {
            "url": "https://pictureexample.jpg"
        }
    };
    bot.sendMessage({
        to: channelID,
        message: embed
    });