Components¶
Classes that are adding some functionality for default components.
Hint
Components in your code are automatically replaced with the ones from this module. You can use discord.ui.View instead of ezcord.View.
- class ezcord.components.DropdownPaginator(options, next_page_label='Next page', previous_page_label='Previous page', next_page_emoji='⬇️', previous_page_emoji='⬆️', page=0, **kwargs)[source]¶
A dropdown paginator that can be used to paginate through a list of options.
This is useful when we have more options than Discord allows in a single dropdown menu.
- Parameters:
options (
list[SelectOption]) – The options that will be displayed in the dropdown.next_page_label (
str) – The label of the next page button.previous_page_label (
str) – The label of the previous page button.next_page_emoji (
str) – The emoji of the next page button.previous_page_emoji (
str) – The emoji of the previous page button.page (
int) – The current page of the dropdown.**kwargs – Additional keyword arguments that are passed to
discord.ui.Select.
- property item_selected¶
Return
Trueif the user selected an item from the dropdown. If the user clicked on the next or previous page button, this will returnFalse.
- check_next_page()[source]¶
Return True if the user clicked on the next page button. In this case, the dropdown menu will be edited.
- Return type:
- check_previous_page()[source]¶
Return True if the user clicked on the previous page button. In this case, the dropdown menu will be edited.
- Return type:
- class ezcord.components.Modal(*args, **kwargs)[source]¶
Base class for all
discord.ui.Modalclasses.
- class ezcord.components.View(*args, ignore_timeout_error=False, **kwargs)[source]¶
- ignore_timeout_errors: bool = False¶
Base class for all
discord.ui.Viewclasses that adds some functionality.- Parameters:
ignore_timeout_error – If
True, views will not raise an exception if an error occurs during the timeout event.
- async interaction_check(interaction)[source]¶
Return
Trueif all custom checks returnTrueor if no custom checks are registered.- Return type:
- async on_check_failure(interaction)[source]¶
Called if
interaction_check()returnsFalse.- Return type:
- ezcord.components.event(coro)[source]¶
A decorator to register custom checks and error handlers for Discord components.
Example
@ezcord.event async def view_check(interaction): return interaction.user.id == 12345 # Returns True or False @ezcord.event async def on_view_check_failure(interaction): await interaction.response.send_message("You can't use this!")