【问题标题】:Embed image doesn't appear discord.js v12嵌入图像不出现 discord.js v12
【发布时间】:2020-10-18 04:34:51
【问题描述】:

我正在尝试从邮件中收集附件,然后将它们发送到嵌入中。我试过这个:

attachment = message.attachments.first()
url = attachment.url

const embedmem = new Discord.MessageEmbed()
    .setColor('#ffffff')
    .setTitle('Title')
    .setDescription('Description')
    .setImage(url)
message.channel.send(embedmem);

但是没有图像出现。如果我做错了什么,请告诉我。

【问题讨论】:

    标签: javascript node.js discord discord.js


    【解决方案1】:

    您应该使用const/let/var 等来定义您的变量(例如附件和 URL)...(取决于您的需要)。

    const Attachment = message.attachments.first(); // Getting the attachment.
    
    const Embed = new Discord.MessageEmbed() // Creating an embed message.
        .setColor("#ffffff")
        .setTitle("Title")
        .setDescription("Description")
        if (Attachment && Attachment.url) {Embed.setImage(Attachment.url)} // If the attachment exists we are adding the image.
    message.channel.send(Embed);
    

    【讨论】:

    • 我试过了,但图像仍然没有出现。
    • 不,图像只是不像以前那样出现了。
    • 您的机器人是否有权发送嵌入链接和图片?
    • 是的,我让机器人自己发送链接并且它工作正常。它只是不适用于附件。
    • 如果你有时间可以帮忙吗?
    猜你喜欢
    • 2022-01-21
    • 2022-01-16
    • 2020-11-28
    • 2021-11-24
    • 2021-08-30
    • 2021-09-06
    • 2020-08-10
    • 2020-11-30
    • 2021-04-14
    相关资源
    最近更新 更多