如何在 Discord.js 中创建帮助菜单的嵌入页面?



我一直在YouTube和StackOverflow问题中搜索,但它与我想创建的内容不匹配。 任何人都可以帮我为不和谐机器人的帮助菜单创建一个嵌入页面吗? 这是我为菜单所做的一些嵌入。

第 1 页

const helpembedbasic = new Discord.MessageEmbed()
.setColor('#E96A00')
.setTitle('Commandlist: Basic')
.addFields(
{ name: '‎', value: '‎' },
{ name: '**r!help**', value: 'Shows a list of all the commands.' },
{ name: '**r!invite**', value: 'Get the invite link for this bot.' },
{ name: '**r!hello (shutting down soon)**', value: 'Just a simple hello.' },
)
.setFooter('Ryam v1b • Help Menu')

第 2 页

const helpembedfun = new Discord.MessageEmbed()
.setColor('#E96A00')
.setTitle('Commandlist: Fun')
.addField(
{ name: '‎', value: '‎' },
{ name: '**r!yeet**', value: 'Yeet peoples you mention, just for fun.' },
{ name: '**r!gn**', value: 'Says goodnight to the mentioned user. Respect them.' },
{ name: '**r!pump**', value: 'Shoot a pump to mentioned user and see how many you damaged them.' },
{ name: '**r!snipe**', value: 'Snipe those scared kids and see how much you damaged them.' },
{ name: '**r!fullsweat**', value: 'Full sweat on a mentioned user and see what you did.' },
)

第 3 页

const helpembedadmin = new Discord.MessageEmbed()
.setColor('#E96A00')
.setTitle('Commandlist: Admin')
.addFields(
{ name: '‎', value: '‎' },
{ name: '**r!ping**', value: 'Test command.' },
{ name: '**r!server**', value: 'Shows the name of the server this bot is on.' },
{ name: '**r!clear**', value: 'Delete/clear messages mentioned.' },
{ name: '**r!avatar**', value: 'Shows the avatar of that person.' },
)

假设您可以获取页码参数:

const embed = new Discord.MessageEmbed().setColor("#E96A00");
switch (pageNumber) {
//if you get it from msg.content it will be a string unless you parse it
case "1":
embed
.setTitle("Command List: Basic")
.addFields(
{ name: '‎', value: '‎' },
{ name: '**r!help**', value: 'Shows a list of all the commands.' },
{ name: '**r!invite**', value: 'Get the invite link for this bot.' },
{ name: '**r!hello (shutting down soon)**', value: 'Just a simple hello.' },
)
.setFooter('Ryam v1b • Help Menu');
break;
case "2":
embed
.setTitle('Commandlist: Fun')
.addField(
{ name: '‎', value: '‎' },
{ name: '**r!yeet**', value: 'Yeet peoples you mention, just for fun.' },
{ name: '**r!gn**', value: 'Says goodnight to the mentioned user. Respect them.' },
{ name: '**r!pump**', value: 'Shoot a pump to mentioned user and see how many you damaged them.' },
{ name: '**r!snipe**', value: 'Snipe those scared kids and see how much you damaged them.' },
{ name: '**r!fullsweat**', value: 'Full sweat on a mentioned user and see what you did.' },
);
break;
case "3":
embed
.setTitle('Commandlist: Admin')
.addFields(
{ name: '‎', value: '‎' },
{ name: '**r!ping**', value: 'Test command.' },
{ name: '**r!server**', value: 'Shows the name of the server this bot is on.' },
{ name: '**r!clear**', value: 'Delete/clear messages mentioned.' },
{ name: '**r!avatar**', value: 'Shows the avatar of that person.' },
);
break;
}
msg.channel.send(embed);

有比硬编码所有字段更好的方法,例如,如果您有一个命令集合,但这是一个不同的主题

在添加字段中应该是。

.addFields([
{},
{},
{}
])

最新更新