简体   繁体   English

嵌入的一个值中的多行(discord.js)

[英]Multiple lines in one value of an embed (discord.js)

I am trying to create for my needs an embed with my discord.js bot.我正在尝试根据我的需要创建一个嵌入我的 discord.js 机器人。 Unfortuanlty I can't figure out how to do multiple lines in one value field.不幸的是,我无法弄清楚如何在一个值字段中执行多行。 I tried with the new line character \n, but this was awful, because my lines were getting really long and unreadable, and you can't just start a new coding line in javascript, because semicolons are optional.我尝试使用换行符 \n,但这很糟糕,因为我的行变得非常长且难以阅读,而且您不能只在 javascript 中开始新的编码行,因为分号是可选的。

Does someone have an idea?有人有想法吗? Here is a template:这是一个模板:

const embed = new Discord.MessageEmbed()
      .setTitle("EVERY ROLE EXPLAINED")
      .setColor(color)
      .addFields(
          {name: "__Column 1__", value: "line 1\n line 2\line three", inline: true},
          {name: "__Column 2__", value: "line 1\n line 2\line three", inline: true}
      )

You can use the backtick (`) key您可以使用反引号 (`) 键

 // with backtick console.log(`line 1 line 2 line 3`) // without backtick console.log('line 1\nline 2\nline 3') // same results


Another idea would be to concatenate multiple strings in a new line.另一个想法是在一个新行中连接多个字符串。

 // with concatenation console.log('line 1\n' + 'line 2\n' + 'line 3\n') // without concatenation console.log('line 1\nline 2\nline 3') // same results

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM