Sending an image without the link showing with discord library

梦想与她 提交于 2019-12-11 00:55:54

问题


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


来源:https://stackoverflow.com/questions/49622374/sending-an-image-without-the-link-showing-with-discord-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!