create_button
Function
Creates a button. Values passed in data travel inside the custom_id and come back on click.
from discord_interactions import create_buttonSignature
def create_button( custom_id: str = '', label: str = '', style: str | int = 1, emoji: str | Dict[str, Any] | Any | None = None, data: Dict[str, Any] | None = None, disabled: bool = False, url: str | None = None, sku_id: int | str | None = None, component_id: int | None = None,) -> Dict[str, Any]Parameters
| Name | Type | Default | Description |
|---|---|---|---|
custom_id | str | '' | Base identifier, sent back on click. Must be unique within the message. |
label | str | '' | Button text (80 characters max). |
style | str | int | 1 | Style: a name ("primary", "success", "danger") or a ButtonStyle number. |
emoji | str | Dict[str, Any] | Any | None | None | Unicode emoji, custom emoji "<:name:id>", dict or discord.PartialEmoji. |
data | Dict[str, Any] | None | None | JSON dict embedded in the custom_id (100 characters in total). |
disabled | bool | False | Greyed out and not clickable. |
url | str | None | None | External link: the button becomes a Link button. |
sku_id | int | str | None | None | SKU to purchase: the button becomes a Premium button. |
component_id | int | None | None | Optional numeric identifier, unique within the message. |
Returns
Dict[str, Any] The button dict (type 2).
Example
from discord_interactions import create_action_row, create_button bouton = create_button( "acheter", "Acheter", style="success", emoji="<:piece:123456789012345678>", data={"article": 42},)await ctx.respond("Boutique", components=[create_action_row(bouton)])