2.1.2 • Published 1 year ago

discord.js-menu-buttons v2.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

discord.js-menu-buttons

At first I would like to clarify that this package is just a modification to an already existing package discord.js-menu-reactions but since the autor of that package is unactive and the package is stuck in discord.jsV12 I made a modified version of this package that is up to date. Also some of the readme will be stripped of right from the original package since I'm too lazy to type this shit in.

Docs

Here are the docs for the module although you can see the usage below

Usage

Using this package is quite simple and simmilar to the original so if you've used Jowsey's package before you'll be familiar with this setup. In this example I'm creating a menu that has 2 pages, "page 1" and "page 2". "page 1" has two buttons one for the bot to send a message saying hello and the other to move to page 2. All of the code will be in typescript (and I highly encourage you to use it). Everything in the bot is documented in typescript so you don't have to worry about not working intelisense.

Initializing

The bot requires giving it a client variable since InteractionCollector needs it. To initialize the bot you have to execute the function named setClient

import { Client, MessageEmbed } from "discord.js";
import { Menu } from "discord.js-menu-buttons";
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
setClient(client);

Menu

const menu = new Menu(message.channel, message.author.id, [
{
    name: "page1",
    content: new MessageEmbed().setTitle("Hello!"),
    rows: [
        new Row([
            new ButtonOption(
                {
                    customId: "thisHasToBeRandomAndDifferentFromEveryButton",
                    style: "PRIMARY",
                    label: "Button1"
                },
                (i) => {
                    i.deferUpdate();
                    console.log("Clicked button1 " + i.customId)
                }
            ),
            new ButtonOption(
                {
                    customId: "thisHasToBeRandomAndDifferentFromEveryButton1",
                    style: "PRIMARY",
                    label: "Button2"
                },
                (i) => {
                    i.deferUpdate();
                    console.log("Clicked button1 " + i.customId)
                    
                }
            )
        ], RowTypes.ButtonMenu),
        new Row([
            new MenuOption(
                {
                    label: "lbl",
                    value: "value",
                },
                (i) => {
                    i.deferUpdate();
                    console.log(i.values[0]); //value
                }
            )
        ], RowTypes.SelectMenu),
        new Row([
            new MenuOption(
                {
                    label: "label",
                    description: "description",
                    value: "val"
                },
                "page2"
            )
        ], RowTypes.SelectMenu)
    ]
},
{
    name: "page2",
    content: new MessageEmbed().setTitle("Page2"),
    rows: [
        new Row([
            new MenuOption(
                {
                    label: "label1",
                    value: "value1",
                },
                (i) => {
                    i.deferUpdate();
                    console.log(i.values[0]);
                }
            ),
            new MenuOption(
                {
                    label: "go to page1",
                    value: "value2"
                },
                "page1"
            )
        ], RowTypes.SelectMenu)
    ]
}
])
menu.start();

Special Destinations

You may have noticed I mentioned "special destinations" above.
discord.js-menu-buttons comes with 6 pre-defined destinations with specific uses.

DestinationFunction
firstGoes to the first page in the array.
lastGoes to the last page in the array.
previousGoes to the previous page in the array.
nextGoes to the next page in the array.
stopRemoves reactions from the embed and stops updating the menu.
deleteStops the menu and deletes the message.

Note that whilst calling a page one of these wouldn't break anything (the page would still be accessible using, ironically, the special destinations) you wouldn't be able to directly link to it.

Support

You can visit this support discord.

Acknowledgements

Major parts of this project were by Jowsey's discord.js-menu.

2.1.2

1 year ago

2.1.1

1 year ago

2.1.0

1 year ago

2.0.3

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.8

2 years ago

1.0.9

2 years ago

1.1.7

2 years ago

1.0.8

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago