Skip to main content

Register a command

import { defineCommand } from '@impulsedev/chameleon'

const ping = defineCommand({
  name: 'ping',
  description: 'Return latency information',
  execute: async (ctx) => {
    await ctx.reply({
      content: `Gateway: ${client.gateway.ms}ms`,
      ephemeral: true
    })
  }
})

client.commands.register(ping)

Register a button handler

import { defineButton } from '@impulsedev/chameleon'

client.components.register(
  defineButton({
    customId: 'open_modal',
    style: 'primary',
    label: 'Open modal',
    execute: async (ctx) => {
      await ctx.reply({ content: 'clicked', ephemeral: true })
    }
  })
)
If you only need the visual button definition for a message payload, use Button.*:
import { Button } from '@impulsedev/chameleon'

const openModalButton = Button.primary('open_modal', 'Open modal')

Send classic V1 components

import { ActionRow, Button } from '@impulsedev/chameleon'

await client.messages.send(channelId, {
  content: 'Classic components',
  components: [
    ActionRow.of(
      Button.primary('open_modal', 'Open modal')
    )
  ]
})

Notes

  • Classic message components are row-based because that is how Discord models V1 component payloads.
  • The same Button.* helpers also work inside Components V2 accessory flows.
  • Use defineButton(...) or Button.of(...) when the component also needs an execute handler.
Last modified on June 13, 2026