Components
cordless has full support for Discord’s Components v2.
Available components
Section titled “Available components”from cordless.components import ( Container, TextDisplay, Separator, MediaGallery, Section, ActionRow, Button, ButtonStyle,)Example
Section titled “Example”from cordless.components import Container, TextDisplay, ActionRow, Button, ButtonStyle
components = [ Container(components=[ TextDisplay("Welcome to my bot!"), ActionRow(components=[ Button("Click me", custom_id="my_button", style=ButtonStyle.PRIMARY), ]), ])]
await ctx.send(components=components)Handling buttons
Section titled “Handling buttons”from cordless import Cog, cog_button
class MyCog(Cog): @cog_button("my_button") async def my_button(self, ctx): await ctx.edit(components=[ Container(components=[TextDisplay("You clicked it!")]) ])Prefix matching
Section titled “Prefix matching”A button with custom_id="action:123" will match a handler registered as "action" — everything after : is ignored. Use ctx.custom_id to read the full ID.
Deferred buttons
Section titled “Deferred buttons”For buttons that take time to process, set defer=True. The message shows a loading state while the worker runs.
@cog_button("slow_button", defer=True)async def slow_button(self, ctx): result = await do_work() await ctx.edit(components=[...])