🔍 /
🏛️ Classes

🔘 Button

Como obter: `Button()`

Métodos

AssinaturaParâmetro(s)Descrição
setLabel(v) string Button text
setStyle(v) string primary · secondary · success · danger · linkver button-style
setCustomId(v) string Permanent. A fixed ID you choose. Never expires — capture it with on(buttonClick, i => { if (i.customId == "v") ... }). Keeps working even after Ayami restarts.
onClick(fn, opts?) function Temporary. Registers the click directly, without needing on(buttonClick). Expires on its own (10min by default). opts: { user: true|"id", ttl: ms }user: true restricts it to the command's author.
setEmoji(e) string Emoji. E.g.: "🎉"
setDisabled(v) bool Disables the button
setURL(v) string URL (only with style link)
📝Permanent vs. temporary: use setCustomId for buttons that need to survive restarts (e.g. a fixed panel). Use onClick for single-use buttons tied to a command (e.g. confirm/cancel), with no separate handler needed.

Exemplo de uso

on command("confirmar", message, args)
  let btn = Button()
    .setLabel("Confirmar")
    .setStyle("success")
    .onClick(function(interaction)
      interaction.reply("✅ Confirmado!")
    end)

  message.reply("Clique para confirmar:", { components: [btn] })
end

Funções ou páginas relacionadas