Sending an image without the link showing with dis

2019-07-14 11:20发布

问题:

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?

回答1:

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
    });