Buttons

Create interactive buttons and handle clicks easily.

Button Handler

Create it inside buttons/verify.ts.

1import { ButtonHandler } from 'discordjs-nextgen';
2
3const verifyButton: ButtonHandler = {
4 customId: 'verify_user',
5 run: async (ctx) => {
6 await ctx.reply({ content: 'You are verified!', ephemeral: true });
7 },
8};
9
10export default verifyButton;

Creating Buttons

Group buttons with ActionRow before sending them in a message.

1import { Button, ActionRow } from 'discordjs-nextgen';
2
3const row = ActionRow.create(
4 Button.create('test_btn')
5 .setLabel('Click')
6 .setStyle('Primary'),
7 Button.create()
8 .setLabel('Google')
9 .setURL('https://google.com')
10);
11
12await ctx.reply({ content: 'Choose a button:', components: [row] });

Features

  • Class-based API for rapid button setup.
  • Automatic customId matching.
  • Clean ActionRow integration.
  • Strong typing for button styles.