【问题标题】:How to send several embeds in one message?如何在一条消息中发送多个嵌入?
【发布时间】:2019-10-23 13:48:36
【问题描述】:

我在查看 discord.js 文档时看到了这个:

.embeds 消息中的嵌入列表 - 例如YouTube 播放器 类型:数组

“列表” :O ? 这意味着可以在一条消息中嵌入多个内容。 我一直在寻找一种方法来做到这一点,但我没有找到任何东西(我知道还有关于堆栈溢出的另一篇文章,但它是非活动的和 unawsnered)

我使用了一个旧代码 channel.send(this.embed()); 并尝试对其进行编辑,以便它发送两个嵌入而不是一个。 this.embed() 运行

{ 
    var builder = new Discord.RichEmbed();
    builder.setTitle(...);
    ...
    return builder
}

第一次尝试是

channel.send(this.embed(), this.embed());
  • 发送[object Object]然后第二个嵌入*
channel.send("", this.embed(), this.embed());
  • 发送第一个嵌入*

然后我查看了更多关于 .send 的文档:

.send([内容] , [选项]) 向此频道发送消息。

废话

示例 4

>// Send an embed with a local image inside
>channel.send('This is an embed', {
>  embed: {
>    thumbnail: {
>         url: 'attachment://file.jpg'
>      }
>   },
>   files: [{
>      attachment: 'entire/path/to/file.jpg',
>      name: 'file.jpg'
>   }]
>})
>  .then(console.log)
>  .catch(console.error);

所以我使用了该示例并尝试为我的案例重现它。 我尝试了很多不同的语法,我不会发布所有的变化^^' 但我想向您展示这两个:

channel.send("", {
                       {embed:this.embed(petit)},
                       {embed:this.embed(petit)}
                    }
               );
  • SyntaxError: Unexpected token {
channel.send("", {
                     embed: [{this.embed(petit), this.embed(petit)}]
                  } );
  • SyntaxError: Unexpected token .

等等……

我觉得我在最后一次尝试中离解决方案更近了,但我仍然错过了一些东西。

我真的很想把我所有的嵌入到 one 消息中,我知道我可以一个一个地发送它们,但我不希望这样 :) 消息中的嵌入量是否也有上限?

感谢阅读,希望我没有写那么多错别字^^

纳尔法维

【问题讨论】:

    标签: embed discord.js


    【解决方案1】:

    您可以使用以下语法发送多个嵌入消息:

    channel.send({
      embed: {
        // Your embedded message's content
      },
      embed: {
        // Your second embedded message's content
      }
    })
    

    【讨论】:

    • 您需要使用embed: { > thumbnail: { > url: 'attachment://file.jpg' > } > }还是仍然可以使用RichEmbed?
    猜你喜欢
    • 2020-04-21
    • 2019-11-24
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-04
    相关资源
    最近更新 更多