Skip to main content


Components allow users to interact with your bot through interactive UI elements. In this section, we will discuss how bots can receive and process information from these elements through the library.

AbhigyanTripsused /buttons
Disnake BotBot03/15/2024
Need help?

The code for this command is given below.
# At the top of the file.
import disnake
from disnake.ext import commands

# The slash command that responds with a message.
async def buttons(inter: disnake.ApplicationCommandInteraction):
await inter.response.send_message(
"Need help?",
disnake.ui.Button(label="Yes", style=disnake.ButtonStyle.success, custom_id="yes"),
disnake.ui.Button(label="No", style=disnake.ButtonStyle.danger, custom_id="no"),

async def help_listener(inter: disnake.MessageInteraction):
if inter.component.custom_id not in ["yes", "no"]:
# We filter out any other button presses except
# the components we wish to process.

if inter.component.custom_id == "yes":
await inter.response.send_message("Contact us at!")
elif inter.component.custom_id == "no":
await inter.response.send_message("Got it. Signing off!")

Building and sending buttons

Button styles

PrimaryButtonStyle.primary / ButtonStyle.blurpleBlurple
SecondaryButtonStyle.secondary / ButtonStyle.grey / ButtonStyle.grayGrey
SuccessButtonStyle.success / Green
DangerButtonStyle.danger / ButtonStyle.redRed / ButtonStyle.urlGrey

Disnake BotBot03/15/2024


Link buttons cannot have a custom_id, and do not send an interaction event when clicked.

Disabled buttons

Receiving button callback

Views vs. low-level components