Event references¶
This serves as a reference for all events that can be used in the bot. The events are divided into categories, and each event has a description of what it does and what parameters it takes.
An example of how one event is used:
import discord_http
client = discord_http.Client(...)
@client.listener()
async def on_ready(user: discord_http.User):
print(f"Logged in as {user}")
If you are trying to get listeners inside a cog, you will need to do the following:
from discord_http import commands, User
@commands.listener()
async def on_ready(self, user: User):
print(f"Logged in as {user}")
Connection¶
- async def on_ready(client)
Called when the bot token has been verified and everything is loaded, ready to start receiving events from Discord. Using this event will disable the default INFO print given by the library, and instead let you decide what it should do.
- Parameters:
user –
User
object with information about the token provided.
- async def on_ping(ping)
Called whenever Discord sends a ping to the bot, checking if the URL provided for interactions is valid. Using this event will disable the default INFO print given by the library, and instead let you decide what it should do.
- Parameters:
ping –
Ping
object that tells what information was sent to the bot.
Webhook¶
- async def on_raw_interaction(data)
Called whenever an interaction is received from Discord. In order to use this event, you must have Client.debug_events set to True, otherwise it will not be called.
- Parameters:
data –
dict
raw dictionary with the interaction data sent by Discord.
Errors¶
- async def on_event_error(client, error)
Called whenever an error occurs in an event (aka. listener)
Using this event will disable the default ERROR print given by the library, and instead let you decide what it should do.
- Parameters:
client –
Client
The client object.error –
Exception
object with the error that occurred.
- async def on_interaction_error(ctx, error):
Called whenever an error occurs in an interaction (command, autocomplete, button, etc.)
Using this event will disable the default ERROR print given by the library, and instead let you decide what it should do.
- Parameters:
ctx –
Context
The context object.error –
Exception
object with the error that occurred.