Reference
Events
What a bot hears, and with what arguments. Define a coroutine of the same name with @client.event, or add a listener. Which events reach a handler is decided by its intent (intents).
Generated from the library: an event it dispatches cannot be missing here.
Connection
on_connect()The gateway's socket is open and signed in. Comes before on_ready, and again on every reconnect.
on_disconnect()The socket closed. The client reconnects by itself, with backoff.
on_guild_available(guild)A server it is in, as it is known at start.
on_ready()Signed in, the servers and channels it is in are known, and anything sent while it was stopped has been handed to on_missed_message. Runs again after a reconnect that had to start over.
on_resumed()A reconnect that carried on where the last connection stopped, with nothing missed.
Messages
on_guild_channel_pins_update(channel, last_pin)A message was pinned or unpinned in a server's channel.
on_message(message)A message, opened and proven: the server relays ciphertext, and the library decrypts it and checks who signed it before you see it. Needs messages.read.
on_message_delete(message)A message the bot holds was deleted by its author or redacted by a moderator.
on_message_edit(before, after)A message the bot holds was edited. before is the copy it held.
on_message_redact(payload)ILLEST's own: a moderator destroyed a message. The server drops the ciphertext for everybody.
on_missed_message(message)ILLEST's own: a message sent while the bot was stopped (the newest 200 of a channel, none older than three days), with message.late set. Never handed to on_message, so a command typed hours ago is not carried out as if it were new.
on_private_channel_pins_update(channel, last_pin)A message was pinned or unpinned in a direct conversation.
on_raw_message_delete(payload)Any deletion, held or not.
on_raw_message_edit(payload)Any edit, whether or not the bot holds the message. payload.cached_message is the copy when it does.
on_raw_typing(payload)The same, as the server sent it.
on_typing(channel, user, when)Somebody started typing. Needs the typing intent, which is off by default.
Reactions
on_raw_reaction_add(payload)Any reaction, held message or not.
on_raw_reaction_remove(payload)Any reaction taken back.
on_reaction_add(reaction, user)Somebody reacted to a message the bot holds.
on_reaction_remove(reaction, user)Somebody took a reaction back.
Interactions and commands
on_app_command_completion(interaction, command)A slash command or context menu finished without raising.
on_command(ctx)A prefix or hybrid command is about to run.
on_command_completion(ctx)A prefix or hybrid command finished without raising.
on_command_error(ctx, error)A prefix or hybrid command raised, or a check or converter refused it.
on_interaction(interaction)Every slash command, context menu, button press, menu pick and form. The command tree and views answer the ones they own before this runs.
Members
on_member_ban(guild, user)Somebody was banned from a server.
on_member_join(member)Somebody joined a server the bot is in. Needs members.read.
on_member_remove(member)Somebody left, or was kicked or banned, and the bot knew them.
on_member_unban(guild, user)A ban was lifted.
on_member_update(before, after)A member's roles, nickname or timeout changed.
on_presence_update(before, after)Somebody's status changed.
on_raw_member_remove(payload)Any member leaving, known or not.
on_user_update(before, after)An account's name, display name or picture changed.
Servers
on_guild_channel_create(channel)A channel was made.
on_guild_channel_delete(channel)A channel was deleted.
on_guild_channel_update(before, after)A channel was renamed, moved or had its permissions changed.
on_guild_join(guild)The bot was added to a server.
on_guild_remove(guild)The bot was removed from a server, or the server was deleted.
on_guild_role_create(role)A role was made.
on_guild_role_delete(role)A role was deleted.
on_guild_role_update(before, after)A role's name, colour, position or permissions changed.
on_guild_update(before, after)A server's name, icon or settings changed.
on_voice_state_update(member, before, after)Somebody joined, left or moved between voice channels. A bot sees who is where; it does not hear the call.
Encryption
on_group_join(channel)ILLEST's own: a member's client let the bot into a channel's encrypted group, so it can read and send there from now on.
on_key_change(user_id)ILLEST's own: an account showed a key other than the one the bot pinned for it. Accept it with client.accept_key_change(user_id) once you trust it.