Frequently Asked Questions
Before asking a question, look at these :)
Before, check you are using the correct library (discord-components not discord-buttons) and if your library is in the newest version.
How to make buttons inline?
Your code must be something like
await <discord.abc.Messageable>.send(
...,
components = [
Button(...),
Button(...),
Button(...)
]
)You should use a two-dimensional array like below to make buttons inline.
await <discord.abc.Messageable>.send(
...,
components = [
[
Button(...),
Button(...),
Button(...)
]
]
)How do I remove components?
Simple. Edit the message with parameter components set to [].
How do I ignore the interaction?
Just respond with the type 6 with no other parameters or defer with edit_origin enabled.
Global event
There is an event on_button_click and on_select_option. You can use this as normal events.
There is an example using cogs on GitLab.
TypeError: send() got an unexpected keyword argument 'components'
Have you put DiscordComponents(<discord.Client or discord.ext.commands.Bot>) inside the on_ready event or initialized the bot with ComponentsBot?
Handle multiple interacts
You should put a while on discord.Client.wait_for to handle multiple clicks
Disabling the components for specific users
This is impossible but you can ignore the interaction by putting a check.
I get ''404 Not Found (error code: 10062): Unknown interaction''
Check if you already responded to the interaction.
Using custom emoji
You send a discord.Emoji object to the parameter. You can get the custom emoji by doing
Can I set my own colors for buttons?
No. Try reading this.
Last updated
Was this helpful?