Events

Event reference, names and parameters passed when calling events

When registering events in the client class, they must be an async function and be called on_event-name.

If using the Client.on() decorator, its preferred to not start the event with on_. However, it will still be accepted.

on_connect

Called when the client first connects to the gateway

on_ready

Called when gateway dispatched READY. Indicating that the client has successfully connected to the gateway.

on_heartbeat

Called when the client has sent a heartbeat and has received a successful response.

on_resume

Called when client connection resumed, meaning that the connection was reset by peer and needed to be reconnected.

Warning

You may notice changes in certain objects so track user made caches.

on_message

Called when gateway dispatches MESSAGE_CREATE. Indicating that a message has just been created.

Parameters

message: Message

Message that was just created

on_message_pin

Called when gateway dispatches CHANNEL_PINS_UPDATE. Indicating a message has been pinned/unpinned.

Note

This event is not called when pinned message is deleted

Parameters

channel: Channel

Channel were message was pinned/unpinned in

timestamp: datetime.datetime

The timestamp of when message was pinned/unpinned

on_guild_create

Called when the gateway dispatches GUILD_CREATE. Indicating the client has joined a new guild, this is different to on_guild_recv.

Parameters

guild: Guild

Guild client has just joined

on_guild_recv

Called when the gateway dispatches GUILD_CREATE. When the client receives a guild clients joined in.

Parameters

guild: Guild

Guild clients in

on_guild_delete

Called when the gateway dispatches GUILD_DELETE. Indicating that the client has just been removed from a server, this is different to on_guild_outage

Parameters

guild: Guild

Guild client was removed from

on_guild_outage

Called when the gateway dispatches GUILD_DELETE. Indicating the client is in a guild that is unavailable due to an outage.

Parameters

guild: Guild

Guild thats experiencing an outage, Guild.unavailable should be true.

on_guild_update

Called when the gateway dispatches GUILD_UPDATE. Indicating that a guild has been modifed.

Parameters

guild: Guild

Guild that has been updated

on_guild_ban

Called when the gateway dispatches GUILD_BAN_ADD. Indicating a user has been banned

Parameters

guild: Guild

Guild were user was banned from

user: User

User who was banned

on_guild_ban_remove

Called when the gateway dispatches GUILD_BAN_REMOVE. Indicating a user has been unbanned

Parameters

guild: Guild

Guild were user was unbanned from

user: User

User who was unbanned

on_emoji_update

Called when the gateway dispatches GUILD_EMOJIS_UPDATE. Indicating an emoji has been updated. This is different to on_emojis_update, as this is a singular emoji not all of them.

Parameters

emoji: Emoji

Emoji just updated

on_emojis_update

Called when the gateway dispatches GUILD_EMOJIS_UPDATE. Indicating many emojis have been updated. this is different to on_emoji_update, as this contains all updated emojis instead of 1.

Parameters

emojis: List[Emoji]

List of updated emojis

on_sticker_update

Called when the gateway dispatches GUILD_STICKERS_UPDATE. Indicating a sticker has been updated. This is different to on_stickers_update, as this is a singular sticker not all of them.

Parameters

sticker: Sticker

Sticker just updated

on_stickers_update

Called when the gateway dispatches GUILD_STICKERS_UPDATE. Indicating many stickers have been updated. this is different to on_stickers_update, as this contains all updated stickers instead of 1.

Parameters

sticker: List[Sticker]

List of updated stickers

on_channel_create

Called when the gateway dispatches CHANNEL_CREATE. This is called when any channels are created.

Parameters

channel: Channel

Channel just created

on_channel_update

Called when the gateway dispatches CHANNEL_UPDATE. This is called when any channels are updated.

Parameters

channel: Channel

Channel that was just updated

on_channel_delete

Called when the gateway dispatches CHANNEL_DELETE. Indicating a channel has been deleted

Parameters

channel: Channel

Channel that was just deleted

on_thread_create

Called when the gateway dispatches THREAD_CREATE. Indicating that a thread has been created.

Parameters

thread: Thread

Thread thats just been created

on_thread_update

Called when the gateway dispatches THREAD_UPDATE. Indicating that a thread has been updated.

Parameters

thread: Thread

Thread thats just been updated

on_thread_delete

Called when the gateway dispatches THREAD_DELETE. Indicating that a thread has been deleted.

Parameters

thread: Thread

Thread thats just been deleted

on_thread_sync

Called when the gateway dispatches THREAD_LIST_SYNC. Indicating that the client has gotten access to new threads.

Parameters

threads: List[Thread]

A list of threads that the client has gained access to.

on_thread_member_update

Called when the gateway dispatches THREAD_MEMBER_UPDATE.

Parameters

thread_member: ThreadMember

Member that has been updated

on_thread_members_update

Called when the gateway dispatches THREAD_MEMBERS_UPDATE.

Parameters

thread_member: Thread

Updated thread, were Thread.members is updated

on_interaction_create

Called when the gateway dispatches INTERACTION_CREATE, indication an interaction was created.

Parameters

interaction: Interaction

Interaction created

on_interaction_update

Called when the gateway dispatches INTERACTION_UPDATE, indication an interaction was updated.

Parameters

interaction: Interaction

Interaction updated

on_interaction_delete

Called when the gateway dispatches INTERACTION_DELETE, indication an interaction was deleted.

Parameters

id: int

ID of interaction deleted

guild_id: Snowflake

ID of guild were interaction was created

application_id: Snowflake

ID of the bot/OAuth2 application for this discord integration