Centralomd
Centralomd

Reputation: 13

how do you create embed pages for help menu in discord.js?

I've been searching in youtube and in a StackOverflow question, but it didn't match what I wanted to create. can anyone help me create an embed page for help menus for discord bots? here are some embeds I made for the menu.

Page 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')

Page 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.' },
  )

Page 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.' },
  )

Upvotes: 0

Views: 4660

Answers (2)

user13429955
user13429955

Reputation:

Well assuming you can get the page number argument:

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);

There are better ways to go about this than hard coding all the fields, like if you had a command collection but that's a different topic

Upvotes: 2

rez
rez

Reputation: 331

in addfields it should be.

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

Upvotes: 0

Related Questions