Events
from discord.ext import commands
from dislash import *
bot = commands.Bot(command_prefix="!")
slash = SlashClient(bot)
Here’re 3 different ways of working with dislash events:
@slash.event
async def on_event():
# ...
@bot.listen()
async def on_event():
# ...
# For cogs
@commands.Cog.listener()
async def on_event(self):
# ...
on_ready
- async events.on_ready()
An event which is activated when the dislash extension is ready and all slash commands are synced (if there’re any)
on_auto_register
- async events.on_auto_register(global_commands_patched, patched_guilds)
An event which is called after auto synchronisation of commands.
- Parameters
global_commands_patched (
bool
) – whether the global application commands were updatedpatched_guilds (
List[int]
) – the list of IDs of guilds where the commands were updated
on_dropdown
- async events.on_dropdown(interaction)
An event which is called on any menu click of your application.
- Parameters
interaction (
MessageInteraction
) – the interaction with the select menu
on_slash_command
- async events.on_slash_command(interaction)
An event which is called every time a slash command of your application is invoked.
- Parameters
interaction (
SlashInteraction
) – the interaction with a slash command
on_user_command
- async events.on_user_command(interaction)
An event which is called every time a user command of your application is invoked.
- Parameters
interaction (
ContextMenuInteraction
) – the interaction with a user command
on_message_command
- async events.on_message_command(interaction)
An event which is called every time a message command of your application is invoked.
- Parameters
interaction (
ContextMenuInteraction
) – the interaction with a message command
on_slash_command_error
- async events.on_slash_command_error(interaction, error)
An event which is called every time a slash command fails due to some error. This also includes
InteractionCheckFailure
- Parameters
interaction (
SlashInteraction
) – the interaction with a slash commanderror (
ApplicationCommandError
) – the error that was raised
on_user_command_error
- async events.on_user_command_error(interaction, error)
An event which is called every time a user command fails due to some error. This also includes
InteractionCheckFailure
- Parameters
interaction (
ContextMenuInteraction
) – the interaction with a user commanderror (
ApplicationCommandError
) – the error that was raised
on_message_command_error
- async events.on_message_command_error(interaction, error)
An event which is called every time a message command fails due to some error. This also includes
InteractionCheckFailure
- Parameters
interaction (
ContextMenuInteraction
) – the interaction with a message commanderror (
ApplicationCommandError
) – the error that was raised