如何让我的嵌入在 Discord.js 中更干净?

How can I make my Embeds more Cleaner in Discord.js?

我想知道如何让我的嵌入看起来更干净。我使用的嵌入样式是这样的:

const Discord = require('discord.js');

        const Embed = new Discord.MessageEmbed()
        .setTitle("The Commands")
        .setColor(0xFF0000)
        .addField("Category:", "`something`", true)
        .addField('\u200b', "`something1`", true)
        .addField('\u200b', "`something2`", true)
        .addField('\u200b', "`something3`", true)
        .addField('\u200b', "`something4`", true)
        .addField('\u200b', "`something5`", true)
        .addField('\u200b', "`something6`", true)
        .addField('\u200b', "`something7`", true)
        .addField('\u200b', "`something8`", true)
        .addField("Category 1:", "`something9`", true)
        .addField('\u200b', "`something10`", true)
        .addField('\u200b', "`something11`", true)
        .addField("Category 2", "`something12`", true)
        .addField('\u200b', "`something13`", true)
        .addField('\u200b', "`something14`", true)
        .addField('\u200b', "`something15`", true);

        message.author.send(Embed)
        message.channel.send(`check your dm's for the commands`);

这段代码的结果是:

这里有点接近我希望嵌入的样子:

您可以通过在您发送的代码中使用 addFields 使添加文件更加清晰,这将让您一次添加多个字段,这样您就不必重复多次

//so for example
Embed.addFields(
                  {name:'hi', value:'hello'},
                  {name:'hi', value:'hello'},
                  {name:'hi', value:'hello'}
)

将它们全部放在一个括号中会更清晰,我认为也可以删除 namevalue

您需要将 .addField 修改为:

.addFields(
{ name: 'Inline field title', value: 'Some value here\n' + 'Some value here\n' + 'Some value here', inline: true },
{ name: 'Inline field title', value: 'Some value here\n' + 'Some value here\n' + 'Some value here', inline: true },
)