Components¶
Classes that are adding some functionality for default components.
Note
If you want to register global checks and error handlers, all Views must
inherit from EzView instead of discord.ui.View.
from ezcord import View
class MyView(View): # right
...
class MyView(discord.ui.View): # wrong
...
- 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!") @ezcord.event async def on_view_error(error, item, interaction): await interaction.response.send_message("Something went wrong!") @ezcord.event async def on_modal_error(error, interaction): await interaction.response.send_message("Something went wrong!")
- class ezcord.components.View(*args, **kwargs)[source]¶
This class extends from
discord.ui.Viewand adds some functionality.- async on_error(error, item, interaction)[source]¶
Sends an error message to a webhook, if the URL was passed in
Bot.Executes all registered error handlers with the
@ezcord.eventdecorator.- Return type:
- async interaction_check(interaction)[source]¶
Returns
Trueif all custom checks returnTrueor if no custom checks are registered.- Return type:
- async on_check_failure(interaction)[source]¶
This method is called if
interaction_check()returnsFalse.- Return type:
- class ezcord.components.Modal(*args, **kwargs)[source]¶
This class extends from
discord.ui.Modaland adds an error handler.