node.js - Discord.js 嵌入消息多行值

标签 node.js discord discord.js

发送嵌入消息的标准方式是:

message.channel.send({embed: {
      color: 3447003,
      title: "Test:",
      fields: [
        { name: "Test 1", value="Test"},
        { name: "Test 2", value: "TEST"},
        { name: "Test 3", value: "TEST"}
      ]
    }
  });

我想知道是否有任何方法可以将消息制成 block 形式,例如:

Test1:                    Test2:
test1                     test1
test2                     test2
test3                     test3
test4                     test4

我的目标是使其内联,并且您可以为每个标题输入多个值。首先,我认为 \n 可以解决问题,但它不起作用。我尝试了一些其他方法,试图向其中添加 embed-manager.js,但它不起作用。

message.channel.send({embed: {
      color: 3447003,
      title: "Test:",
      fields: [
        { name: "Test 1", value="Test1 \n Test2 \n Test3"},
        { name: "Test 2", value: "TEST"},
        { name: "Test 3", value: "TEST"}
      ]
    }
  });

我的目标是这样的: Example picture

感谢您提前提供的帮助。

最佳答案

首先,你不能在对象上使用=。它始终是 :
您可以使用 \n 来制作断线。
您可以使用 inline: true 以便在一行中最多显示 3 个字段。

message.channel.send({embed: {
      color: 3447003,
      title: "Test:",
      fields: [
        { name: "Test 1", value: "Line1\nLine2\nLine3", inline: true},
        { name: "Test 2", value: "AlsoLine1\nAlsoLine2\nAndLine3", inline: true}
      ]
    }
  });

这是这段代码的结果:
Code result

关于node.js - Discord.js 嵌入消息多行值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49334420/

相关文章:

python - 我的代码意外删除了 Discord.py 音乐机器人中的 'song.mp3' 文件

javascript - 在创建不和谐机器人时遇到 .disconnect() 问题

python - 我正在尝试创建一个discord.py赠品命令

javascript - 如何使用discord.js获取特定成员(member)用户名

javascript - 如何在控制台中列出我的机器人所在的所有 Discord 服务器 ID? |不和谐.js

node.js - 如何在node.js中使用app.js访问 session

node.js - 尝试批量插入行时发生 Knexjs 错误 : Timeout acquiring a connection. 池可能已满。

javascript - ROBLOX Discord 机器人

node.js - npm 错误!尝试获取时响应超时

node.js - 当从 Visual Studio 运行 IISExpress 时,我必须采取哪些步骤才能使 IISExpress 运行 iisnode