Skip to content

Instantly share code, notes, and snippets.

View rgranata1's full-sized avatar

Rich Granata rgranata1

  • Nazareth, PA USA
View GitHub Profile
@rgranata1
rgranata1 / discord-button-example.ts
Created May 30, 2023 20:42
Discord Button Interaction
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, ComponentType } from 'discord.js'
export const execute = async (interaction: CommandInteraction): Promise<void> => {
const buttons = new ActionRowBuilder<ButtonBuilder>()
.addComponents(new ButtonBuilder().setCustomId('ok').setLabel('Ok').setStyle(ButtonStyle.Primary))
.addComponents(new ButtonBuilder().setCustomId('cancel').setLabel('Cancel').setStyle(ButtonStyle.Secondary))
const message = await interaction.reply({ content: 'Run Sample?', components: [buttons] })
try {