Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Latest commit

 

History

History
executable file
·
43 lines (40 loc) · 959 Bytes

File metadata and controls

executable file
·
43 lines (40 loc) · 959 Bytes

Button Interaction

Format

// This format is for the button file that you will create in `src/interactions/buttons`.
export const Button = {
    name: "button's CustomId",
    // Other Command Options
    run: async(interaction, client) => {
        // code
    }
};

Example Code

Button Creation Code

import { ButtonBuilder, ActionRowBuilder } from "discord.js";

const row: ActionRowBuilder<ButtonBuilder> = new ActionRowBuilder().addComponents(
    new ButtonBuilder()
    .setCustomId('evalbutton')
    .setLabel('Delete Output')
    .setStyle('Danger'),
);
message.channel.send({
    content: "This is a button",
    components: [row]
});

Button Code

// Code for the `src/interactions/buttons/evalButton.js
export const Button = {
    name: "evalbuttton",
    // Other Command Options
    run: (interaction) => {
        interaction.reply({
            content: "This button is working!"
        });
    }
};