尝试在 discord.js 嵌入机器人的列中显示玩家姓名
Trying to show player names in a column in discord.js embed bot
大家好,我正在尝试弄清楚如何嵌入基本上显示球队名单的机器人,但我不知道如何在列中制作球队球员的名字。我试着把它放在 .addfield 中,但没有用。这是我正在尝试做的一个例子 1
case 'roster':
const roster = new Discord.MessageEmbed()
.setTitle('FinalSpark')
.setDescription('Rank: 3 | Region: EU | League: CCL')
.setURL('https://club.mpcleague.com')
.setFooter('bot made by alex :D')
.addField('Roster')
message.channel.send(roster);
break;
看起来嵌入使用了两个字段,第二个字段的标题为空
你应该这样做的方法是首先将你的花名册列表放入一个数组,然后将数组分成两半:
//your roster array
const roster = [];
//round up so the first row always either has equal or more items
//use Math.floor() if you want the opposite
const midIndex = Math.ceil(roster.length / 2);
const firstRow = roster.slice(0, midIndex);
const secondRow = roster.slice(midIndex);
const embed = new Discord.MessageEmbed()
.setTitle('FinalSpark')
.setDescription('Rank: 3 | Region: EU | League: CCL')
.setURL('https://club.mpcleague.com')
.addField("Roster", firstRow.join("\n"), true);
if (secondRow.length) {
// \u200b is what makes the invisble effect, you can have \u200b
// for both the key and value which would essentially make a blank line
embed.addField("\u200b", secondRow.join("\n"), true);
}
message.channel.send(embed);
那当然会在 case 语句中。
大家好,我正在尝试弄清楚如何嵌入基本上显示球队名单的机器人,但我不知道如何在列中制作球队球员的名字。我试着把它放在 .addfield 中,但没有用。这是我正在尝试做的一个例子 1
case 'roster':
const roster = new Discord.MessageEmbed()
.setTitle('FinalSpark')
.setDescription('Rank: 3 | Region: EU | League: CCL')
.setURL('https://club.mpcleague.com')
.setFooter('bot made by alex :D')
.addField('Roster')
message.channel.send(roster);
break;
看起来嵌入使用了两个字段,第二个字段的标题为空
你应该这样做的方法是首先将你的花名册列表放入一个数组,然后将数组分成两半:
//your roster array
const roster = [];
//round up so the first row always either has equal or more items
//use Math.floor() if you want the opposite
const midIndex = Math.ceil(roster.length / 2);
const firstRow = roster.slice(0, midIndex);
const secondRow = roster.slice(midIndex);
const embed = new Discord.MessageEmbed()
.setTitle('FinalSpark')
.setDescription('Rank: 3 | Region: EU | League: CCL')
.setURL('https://club.mpcleague.com')
.addField("Roster", firstRow.join("\n"), true);
if (secondRow.length) {
// \u200b is what makes the invisble effect, you can have \u200b
// for both the key and value which would essentially make a blank line
embed.addField("\u200b", secondRow.join("\n"), true);
}
message.channel.send(embed);
那当然会在 case 语句中。