【问题标题】:discord.js bot reports [object object] when trying to send an embeddiscord.js 机器人在尝试发送嵌入时报告 [object object]
【发布时间】:2020-06-29 01:43:06
【问题描述】:

我正在编写一个必须发送嵌入的机器人。但是当发送嵌入时,机器人会说[object Object]。


嵌入代码:

const embed9 = new Discord.MessageEmbed()
            .setTitle("1h Until Convoy - Sim1")
            .setURL("https://www.scanialtd.com/")
            .setColor(16571139)
            .setDescription("There is 1 hour untill the convoy on Simulation 1 in ETS2. Get ready to join by launching ETS2 and logging on to Simulation 1. Join the Convoy Lounge while you wait.")
            .setFooter("Created by ScaniaLTD Convoy Announcements Bot, https://www.scanialtd.com/uploads/6/3/4/9/63493649/published/logo_3.png")
            .setImage("http://i.imgur.com/yVpymuV.png")
            .setThumbnail("https://www.scanialtd.com/uploads/6/3/4/9/63493649/published/logo_3.png")
            .setTimestamp()
        message.channel.send('@ConvoyReminders' + {embed9})

【问题讨论】:

  • 简化标题和问题

标签: javascript embed discord discord.js


【解决方案1】:

您正在连接一个字符串和一个内部带有 embed9 的对象。

要提及某人,您需要在.setDescription 中添加@<Username>。那你就可以message.channel.send(embed9)

【讨论】:

    【解决方案2】:

    因为您尝试在 1 个参数中发送搅拌 + 嵌入对象。 你不能用他们的name + @ 来提及他们,你需要使用user.id 来表示这个,比如<@213123131321> 或<@&1232312123132> 来表示角色。

    正确的方式:

    const embed9 = new Discord.MessageEmbed()
                .setTitle("1h Until Convoy - Sim1")
                .setURL("https://www.scanialtd.com/")
                .setColor(16571139)
                .setDescription("There is 1 hour untill the convoy on Simulation 1 in ETS2. Get ready to join by launching ETS2 and logging on to Simulation 1. Join the Convoy Lounge while you wait.")
                .setFooter("Created by ScaniaLTD Convoy Announcements Bot, https://www.scanialtd.com/uploads/6/3/4/9/63493649/published/logo_3.png")
                .setImage("http://i.imgur.com/yVpymuV.png")
                .setThumbnail("https://www.scanialtd.com/uploads/6/3/4/9/63493649/published/logo_3.png")
                .setTimestamp()
    
            message.channel.send('@ConvoyReminders', embed9)
    

    【讨论】:

      猜你喜欢
      • 2020-09-15
      • 2021-05-08
      • 1970-01-01
      • 2019-09-20
      • 2021-01-09
      • 2017-10-31
      • 1970-01-01
      • 1970-01-01
      • 2021-07-22
      相关资源
      最近更新 更多