Buttons
Create interactive buttons and handle clicks easily.
Button Handler
Create it inside buttons/verify.ts.
1import { ButtonHandler } from 'discordjs-nextgen';23const verifyButton: ButtonHandler = {4 customId: 'verify_user',5 run: async (ctx) => {6 await ctx.reply({ content: 'You are verified!', ephemeral: true });7 },8};910export default verifyButton;
Creating Buttons
Group buttons with ActionRow before sending them in a message.
1import { Button, ActionRow } from 'discordjs-nextgen';23const 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);1112await 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.