发送不带Discord库显示的链接的图像 [英] Sending an image without the link showing with discord library

查看:223
本文介绍了发送不带Discord库显示的链接的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的不和谐机器人发送图像(通过url),但是在聊天中发送的消息中隐藏了该url.对于发送消息,即时消息使用switch语句,该语句仅使用!"之后的文字

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?

推荐答案

正如user4261590所写,您可以使用嵌入来实现此目的.这是一个可能适合您的示例:

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

这篇关于发送不带Discord库显示的链接的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆