button() declares a button, from any file of src/; the name of its export is its id. It takes one object, ButtonConfig, and types run from it.
src/components/confirm.ts
How to write a button, carry data in it and answer a click is in the guide. This page lists what exists.
button()
src/: the name of the export is what tells the button apart, so you never write an id.
Data and Where are inferred from what you pass: you never write them.
ButtonDeclaration
Whatbutton() returns: a declaration the framework finds in the exports of a file. Import it where you send a message, and call it with the data the button carries (ban({ userId })); a button without data is used as is (confirm), or called with a look (confirm({ disabled: true })).
ButtonConfig
What a button file gives tobutton(). It has every field of ButtonLook and of InteractiveConfig, plus:
What to do when someone clicks the button. Leave it out for a button that is only waited for (
message.waitForClick()): once nothing waits, a click answers that it is not available any more. See Waiting for an answer.label or an emoji.
ButtonLook
What a button looks like. Everything is optional when it is put in a message: what the file says is the default.The text on the button (80 characters at most): written as is, or a function of
t and the data, run when the message is sent. See DynamicText.ButtonStyleName
'primary' (blurple), 'secondary' (grey), 'success' (green) or 'danger' (red). Link and premium buttons are made with linkButton() and premiumButton().
Discord documentation
ButtonContext
Whatrun receives when the button is clicked: everything of InteractiveContext, and the place as PlaceOf gives it for Where, with a ComponentInteraction.
Shared by buttons and select menus
InteractiveConfig
What every interactive component declares, besides what it looks like.What the component carries from the message that shows it to the code that runs when it is used: a name and a kind for each value (
{ userId: 'string', page: 'number' }). Given when the component is put in a message, received typed in run. Discord keeps it in the component itself, so it survives restarts.Where the component can be used:
'guild' (in servers, the default), 'dm' (in private messages with the bot) or 'both'. What run receives follows it.Who may use it:
'everyone' (the default) or only the 'author' of the command the message answers.Make the answers of the component only visible to who used it. On a message only the person sees (an ephemeral answer), they already are.
InteractiveContext
What every interactive component gives to itsrun, besides the place.
Every component also receives t when the project has a language: see TranslationContext.
ComponentWhere
'guild'), in private messages with the bot ('dm'), or in both. A component is where the message that holds it is: this says where your code expects it.
ComponentWho
'everyone' who sees the message (the default), or only the 'author', the person who used the command the message answers. Anyone else gets a private refusal.
Data
DataKind
data.
DataField
DataShape
DataValuesOf
data declaration, typed from it: what run and the texts of the component receive. A value with a default is always there.
DataInputOf
data, those with a default value being optional.
The place
Whatrun receives about where the component was used follows where, like for a command. The same types serve forms, with a ModalInteraction.
PlaceOf
run receives about where it was used, following where.
PlaceInGuild
Whatrun receives about the place, in a server.
PlaceInPrivate
Whatrun receives about the place, in a private message, when it also works in servers (where: 'both').
PlaceInDm
Whatrun receives about the place, when it only works in private messages (where: 'dm').