Event Reference#

This section outlines the different types of events listened by Client.

There are 3 ways to register an event, the first way is through the use of Client.event(). The second way is through subclassing Client and overriding the specific events. The third way is through the use of Client.listen(), which can be used to assign multiple event handlers instead of only one like in Client.event(). For example:

import discord

class MyClient(discord.Client):
    async def on_message(self, message):
        if message.author == self.user:
            return

        if message.content.startswith('$hello'):
            await message.channel.send('Hello World!')


intents = discord.Intents.default()
intents.message_content = True # Needed to see message content
client = MyClient(intents=intents)

# Overrides the 'on_message' method defined in MyClient
@client.event
async def on_message(message: discord.Message):
    print(f"Received {message.content}")

# Assigns an ADDITIONAL handler
@client.listen()
async def on_message(message: discord.Message):
    print(f"Received {message.content}")

# Runs only for the 1st event dispatch. Can be useful for listening to 'on_ready'
@client.listen(once=True)
async def on_ready():
    print("Client is ready!")

If an event handler raises an exception, on_error() will be called to handle it, which defaults to print a traceback and ignoring the exception.

Warning

All the events must be a coroutine. If they aren’t, then you might get unexpected errors. In order to turn a function into a coroutine they must be async def functions.

Application Commands#

discord.on_application_command(context)#

Called when an application command is received.

New in version 2.0.

Parameters:

context (ApplicationContext) – The ApplicationContext associated to the command being received.

discord.on_application_command_completion(context)#

Called when an application command is completed, after any checks have finished.

New in version 2.0.

Parameters:

context (ApplicationContext) – The ApplicationContext associated to the command that was completed.

discord.on_application_command_error(context, exception)#

Called when an application command has an error.

New in version 2.0.

Parameters:
  • context (ApplicationContext) – The ApplicationContext associated to the command that has an error.

  • exception (DiscordException) – The DiscordException associated to the error.

discord.on_unknown_application_command(interaction)#

Called when an application command was not found in the bot’s internal cache.

New in version 2.0.

Parameters:

interaction (Interaction) – The interaction associated to the unknown command.

Audit Logs#

discord.on_audit_log_entry(entry)#

Called when an audit log entry is created.

The bot must have view_audit_log to receive this, and Intents.moderation must be enabled.

New in version 2.5.

Parameters:

entry (AuditLogEntry) – The audit log entry that was created.

discord.on_raw_audit_log_entry(payload)#

Called when an audit log entry is created. Unlike on_audit_log_entry(), this is called regardless of the state of the internal user cache.

The bot must have view_audit_log to receive this, and Intents.moderation must be enabled.

New in version 2.5.

Parameters:

payload (RawAuditLogEntryEvent) – The raw event payload data.

AutoMod#

discord.on_auto_moderation_rule_create(rule)#

Called when an auto moderation rule is created.

The bot must have manage_guild to receive this, and Intents.auto_moderation_configuration must be enabled.

Parameters:

rule (AutoModRule) – The newly created rule.

discord.on_auto_moderation_rule_update(rule)#

Called when an auto moderation rule is updated.

The bot must have manage_guild to receive this, and Intents.auto_moderation_configuration must be enabled.

Parameters:

rule (AutoModRule) – The updated rule.

discord.on_auto_moderation_rule_delete(rule)#

Called when an auto moderation rule is deleted.

The bot must have manage_guild to receive this, and Intents.auto_moderation_configuration must be enabled.

Parameters:

rule (AutoModRule) – The deleted rule.

discord.on_auto_moderation_action_execution(payload)#

Called when an auto moderation action is executed.

The bot must have manage_guild to receive this, and Intents.auto_moderation_execution must be enabled.

Parameters:

payload (AutoModActionExecutionEvent) – The event’s data.

Bans#

discord.on_member_ban(guild, user)#

Called when user gets banned from a Guild.

This requires Intents.moderation to be enabled.

Parameters:
  • guild (Guild) – The guild the user got banned from.

  • user (Union[User, Member]) – The user that got banned. Can be either User or Member depending if the user was in the guild or not at the time of removal.

discord.on_member_unban(guild, user)#

Called when a User gets unbanned from a Guild.

This requires Intents.moderation to be enabled.

Parameters:
  • guild (Guild) – The guild the user got unbanned from.

  • user (User) – The user that got unbanned.

Channels#

discord.on_private_channel_update(before, after)#

Called whenever a private group DM is updated. e.g. changed name or topic.

This requires Intents.messages to be enabled.

Parameters:
  • before (GroupChannel) – The updated group channel’s old info.

  • after (GroupChannel) – The updated group channel’s new info.

discord.on_private_channel_pins_update(channel, last_pin)#

Called whenever a message is pinned or unpinned from a private channel.

Parameters:
  • channel (abc.PrivateChannel) – The private channel that had its pins updated.

  • last_pin (Optional[datetime.datetime]) – The latest message that was pinned as an aware datetime in UTC. Could be None.

discord.on_guild_channel_update(before, after)#

Called whenever a guild channel is updated. e.g. changed name, topic, permissions.

This requires Intents.guilds to be enabled.

Parameters:
discord.on_guild_channel_pins_update(channel, last_pin)#

Called whenever a message is pinned or unpinned from a guild channel.

This requires Intents.guilds to be enabled.

Parameters:
  • channel (Union[abc.GuildChannel, Thread]) – The guild channel that had its pins updated.

  • last_pin (Optional[datetime.datetime]) – The latest message that was pinned as an aware datetime in UTC. Could be None.

discord.on_guild_channel_delete(channel)#
discord.on_guild_channel_create(channel)#

Called whenever a guild channel is deleted or created.

Note that you can get the guild from guild.

This requires Intents.guilds to be enabled.

Parameters:

channel (abc.GuildChannel) – The guild channel that got created or deleted.

Connection#

discord.on_error(event, *args, **kwargs)#

Usually when an event raises an uncaught exception, a traceback is printed to stderr and the exception is ignored. If you want to change this behaviour and handle the exception for whatever reason yourself, this event can be overridden. Which, when done, will suppress the default action of printing the traceback.

The information of the exception raised and the exception itself can be retrieved with a standard call to sys.exc_info().

If you want exception to propagate out of the Client class you can define an on_error handler consisting of a single empty raise statement. Exceptions raised by on_error will not be handled in any way by Client.

Note

on_error will only be dispatched to Client.event().

It will not be received by Client.wait_for(), or, if used, Bots listeners such as listen() or listener().

Parameters:
  • event (str) – The name of the event that raised the exception.

  • args – The positional arguments for the event that raised the exception.

  • kwargs – The keyword arguments for the event that raised the exception.

discord.on_connect()#

Called when the client has successfully connected to Discord. This is not the same as the client being fully prepared, see on_ready() for that.

The warnings on on_ready() also apply.

Warning

Overriding this event will not call Bot.sync_commands(). As a result, ApplicationCommand will not be registered.

discord.on_shard_connect(shard_id)#

Similar to on_connect() except used by AutoShardedClient to denote when a particular shard ID has connected to Discord.

New in version 1.4.

Parameters:

shard_id (int) – The shard ID that has connected.

discord.on_disconnect()#

Called when the client has disconnected from Discord, or a connection attempt to Discord has failed. This could happen either through the internet being disconnected, explicit calls to close, or Discord terminating the connection one way or the other.

This function can be called many times without a corresponding on_connect() call.

discord.on_shard_disconnect(shard_id)#

Similar to on_disconnect() except used by AutoShardedClient to denote when a particular shard ID has disconnected from Discord.

New in version 1.4.

Parameters:

shard_id (int) – The shard ID that has disconnected.

discord.on_ready()#

Called when the client is done preparing the data received from Discord. Usually after login is successful and the Client.guilds and co. are filled up.

Warning

This function is not guaranteed to be the first event called. Likewise, this function is not guaranteed to only be called once. This library implements reconnection logic and thus will end up calling this event whenever a RESUME request fails.

discord.on_shard_ready(shard_id)#

Similar to on_ready() except used by AutoShardedClient to denote when a particular shard ID has become ready.

Parameters:

shard_id (int) – The shard ID that is ready.

discord.on_resumed()#

Called when the client has resumed a session.

discord.on_shard_resumed(shard_id)#

Similar to on_resumed() except used by AutoShardedClient to denote when a particular shard ID has resumed a session.

New in version 1.4.

Parameters:

shard_id (int) – The shard ID that has resumed.

discord.on_socket_event_type(event_type)#

Called whenever a WebSocket event is received from the WebSocket.

This is mainly useful for logging how many events you are receiving from the Discord gateway.

New in version 2.0.

Parameters:

event_type (str) – The event type from Discord that is received, e.g. 'READY'.

discord.on_socket_raw_receive(msg)#

Called whenever a message is completely received from the WebSocket, before it’s processed and parsed. This event is always dispatched when a complete message is received and the passed data is not parsed in any way.

This is only really useful for grabbing the WebSocket stream and debugging purposes.

This requires setting the enable_debug_events setting in the Client.

Note

This is only for the messages received from the client WebSocket. The voice WebSocket will not trigger this event.

Parameters:

msg (str) – The message passed in from the WebSocket library.

discord.on_socket_raw_send(payload)#

Called whenever a send operation is done on the WebSocket before the message is sent. The passed parameter is the message that is being sent to the WebSocket.

This is only really useful for grabbing the WebSocket stream and debugging purposes.

This requires setting the enable_debug_events setting in the Client.

Note

This is only for the messages sent from the client WebSocket. The voice WebSocket will not trigger this event.

Parameters:

payload – The message that is about to be passed on to the WebSocket library. It can be bytes to denote a binary message or str to denote a regular text message.

Entitlements#

discord.on_entitlement_create(entitlement)#

Called when a user subscribes to an SKU.

New in version 2.5.

Parameters:

entitlement (Entitlement) – The entitlement that was created as a result of the subscription.

discord.on_entitlement_update(entitlement)#

Called when a user’s subscription to an Entitlement is renewed for the next billing period.

New in version 2.5.

Parameters:

entitlement (Entitlement) – The entitlement that was updated.

discord.on_entitlement_delete(entitlement)#

Called when a user’s entitlement is deleted.

Entitlements are usually only deleted when Discord issues a refund for a subscription, or manually removes an entitlement from a user.

Note

This is not called when a user’s subscription is cancelled.

New in version 2.5.

Parameters:

entitlement (Entitlement) – The entitlement that was deleted.

Guilds#

discord.on_guild_join(guild)#

Called when a Guild is either created by the Client or when the Client joins a guild.

This requires Intents.guilds to be enabled.

Parameters:

guild (Guild) – The guild that was joined.

discord.on_guild_remove(guild)#

Called when a Guild is removed from the Client.

This happens through, but not limited to, these circumstances:

  • The client got banned.

  • The client got kicked.

  • The client left the guild.

  • The client or the guild owner deleted the guild.

In order for this event to be invoked then the Client must have been part of the guild to begin with. (i.e. it is part of Client.guilds)

This requires Intents.guilds to be enabled.

Parameters:

guild (Guild) – The guild that got removed.

discord.on_guild_update(before, after)#

Called when a Guild is updated, for example:

  • Changed name

  • Changed AFK channel

  • Changed AFK timeout

  • etc.

This requires Intents.guilds to be enabled.

Parameters:
  • before (Guild) – The guild prior to being updated.

  • after (Guild) – The guild after being updated.

discord.on_guild_role_create(role)#
discord.on_guild_role_delete(role)#

Called when a Guild creates or deletes a Role.

To get the guild it belongs to, use Role.guild.

This requires Intents.guilds to be enabled.

Parameters:

role (Role) – The role that was created or deleted.

discord.on_guild_role_update(before, after)#

Called when a Role is changed guild-wide.

This requires Intents.guilds to be enabled.

Parameters:
  • before (Role) – The updated role’s old info.

  • after (Role) – The updated role’s updated info.

discord.on_guild_emojis_update(guild, before, after)#

Called when a Guild adds or removes an Emoji.

This requires Intents.emojis_and_stickers to be enabled.

Parameters:
  • guild (Guild) – The guild who got their emojis updated.

  • before (Sequence[Emoji]) – A list of emojis before the update.

  • after (Sequence[Emoji]) – A list of emojis after the update.

discord.on_guild_stickers_update(guild, before, after)#

Called when a Guild adds or removes a sticker.

This requires Intents.emojis_and_stickers to be enabled.

New in version 2.0.

Parameters:
  • guild (Guild) – The guild who got their stickers updated.

  • before (Sequence[GuildSticker]) – A list of stickers before the update.

  • after (Sequence[GuildSticker]) – A list of stickers after the update.

discord.on_guild_available(guild)#
discord.on_guild_unavailable(guild)#

Called when a guild becomes available or unavailable. The guild must have existed in the Client.guilds cache.

This requires Intents.guilds to be enabled.

Parameters:

guild (Guild) – The guild that has changed availability.

discord.on_webhooks_update(channel)#

Called whenever a webhook is created, modified, or removed from a guild channel.

This requires Intents.webhooks to be enabled.

Parameters:

channel (abc.GuildChannel) – The channel that had its webhooks updated.

Integrations#

discord.on_guild_integrations_update(guild)#

Called whenever an integration is created, modified, or removed from a guild.

This requires Intents.integrations to be enabled.

New in version 1.4.

Parameters:

guild (Guild) – The guild that had its integrations updated.

discord.on_integration_create(integration)#

Called when an integration is created.

This requires Intents.integrations to be enabled.

New in version 2.0.

Parameters:

integration (Integration) – The integration that was created.

discord.on_integration_update(integration)#

Called when an integration is updated.

This requires Intents.integrations to be enabled.

New in version 2.0.

Parameters:

integration (Integration) – The integration that was created.

discord.on_raw_integration_delete(payload)#

Called when an integration is deleted.

This requires Intents.integrations to be enabled.

New in version 2.0.

Parameters:

payload (RawIntegrationDeleteEvent) – The raw event payload data.

Interactions#

discord.on_interaction(interaction)#

Called when an interaction happened.

This currently happens due to application command invocations or components being used.

Warning

This is a low level function that is not generally meant to be used. If you are working with components, consider using the callbacks associated with the View instead as it provides a nicer user experience.

New in version 2.0.

Parameters:

interaction (Interaction) – The interaction data.

Invites#

discord.on_invite_create(invite)#

Called when an Invite is created. You must have the manage_channels permission to receive this.

New in version 1.3.

Note

There is a rare possibility that the Invite.guild and Invite.channel attributes will be of Object rather than the respective models.

This requires Intents.invites to be enabled.

Parameters:

invite (Invite) – The invite that was created.

discord.on_invite_delete(invite)#

Called when an Invite is deleted. You must have the manage_channels permission to receive this.

New in version 1.3.

Note

There is a rare possibility that the Invite.guild and Invite.channel attributes will be of Object rather than the respective models.

Outside of those two attributes, the only other attribute guaranteed to be filled by the Discord gateway for this event is Invite.code.

This requires Intents.invites to be enabled.

Parameters:

invite (Invite) – The invite that was deleted.

Members/Users#

discord.on_member_join(member)#

Called when a Member joins a Guild.

This requires Intents.members to be enabled.

Parameters:

member (Member) – The member who joined.

discord.on_member_remove(member)#

Called when a Member leaves a Guild.

If the guild or member could not be found in the internal cache, this event will not be called. Alternatively, on_raw_member_remove() is called regardless of the internal cache.

This requires Intents.members to be enabled.

Parameters:

member (Member) – The member who left.

discord.on_raw_member_remove(payload)#

Called when a Member leaves a Guild. Unlike on_member_remove(), this is called regardless of the state of the internal member cache.

This requires Intents.members to be enabled.

New in version 2.4.

Parameters:

payload (RawMemberRemoveEvent) – The raw event payload data.

discord.on_member_update(before, after)#

Called when a Member updates their profile.

This is called when one or more of the following things change:

  • nickname

  • roles

  • pending

  • communication_disabled_until

  • timed_out

This requires Intents.members to be enabled.

Parameters:
  • before (Member) – The updated member’s old info.

  • after (Member) – The updated member’s updated info.

discord.on_presence_update(before, after)#

Called when a Member updates their presence.

This is called when one or more of the following things change:

  • status

  • activity

This requires Intents.presences and Intents.members to be enabled.

New in version 2.0.

Parameters:
  • before (Member) – The updated member’s old info.

  • after (Member) – The updated member’s updated info.

discord.on_voice_state_update(member, before, after)#

Called when a Member changes their VoiceState.

The following, but not limited to, examples illustrate when this event is called:

  • A member joins a voice or stage channel.

  • A member leaves a voice or stage channel.

  • A member is muted or deafened by their own accord.

  • A member is muted or deafened by a guild administrator.

This requires Intents.voice_states to be enabled.

Parameters:
  • member (Member) – The member whose voice states changed.

  • before (VoiceState) – The voice state prior to the changes.

  • after (VoiceState) – The voice state after the changes.

discord.on_user_update(before, after)#

Called when a User updates their profile.

This is called when one or more of the following things change:

  • avatar

  • username

  • discriminator

  • global_name

This requires Intents.members to be enabled.

Parameters:
  • before (User) – The updated user’s old info.

  • after (User) – The updated user’s updated info.

Messages#

discord.on_message(message)#

Called when a Message is created and sent.

This requires Intents.messages to be enabled.

Warning

Your bot’s own messages and private messages are sent through this event. This can lead cases of ‘recursion’ depending on how your bot was programmed. If you want the bot to not reply to itself, consider checking the user IDs. Note that Bot does not have this problem.

Parameters:

message (Message) – The current message.

discord.on_message_delete(message)#

Called when a message is deleted. If the message is not found in the internal message cache, then this event will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the max_messages parameter or use the on_raw_message_delete() event instead.

This requires Intents.messages to be enabled.

Parameters:

message (Message) – The deleted message.

discord.on_bulk_message_delete(messages)#

Called when messages are bulk deleted. If none of the messages deleted are found in the internal message cache, then this event will not be called. If individual messages were not found in the internal message cache, this event will still be called, but the messages not found will not be included in the messages list. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the max_messages parameter or use the on_raw_bulk_message_delete() event instead.

This requires Intents.messages to be enabled.

Parameters:

messages (List[Message]) – The messages that have been deleted.

discord.on_raw_message_delete(payload)#

Called when a message is deleted. Unlike on_message_delete(), this is called regardless of the message being in the internal message cache or not.

If the message is found in the message cache, it can be accessed via RawMessageDeleteEvent.cached_message

This requires Intents.messages to be enabled.

Parameters:

payload (RawMessageDeleteEvent) – The raw event payload data.

discord.on_raw_bulk_message_delete(payload)#

Called when a bulk delete is triggered. Unlike on_bulk_message_delete(), this is called regardless of the messages being in the internal message cache or not.

If the messages are found in the message cache, they can be accessed via RawBulkMessageDeleteEvent.cached_messages

This requires Intents.messages to be enabled.

Parameters:

payload (RawBulkMessageDeleteEvent) – The raw event payload data.

discord.on_message_edit(before, after)#

Called when a Message receives an update event. If the message is not found in the internal message cache, then these events will not be called. Messages might not be in cache if the message is too old or the client is participating in high traffic guilds.

If this occurs increase the max_messages parameter or use the on_raw_message_edit() event instead.

The following non-exhaustive cases trigger this event:

  • A message has been pinned or unpinned.

  • The message content has been changed.

  • The message has received an embed.

    • For performance reasons, the embed server does not do this in a “consistent” manner.

  • The message’s embeds were suppressed or unsuppressed.

  • A call message has received an update to its participants or ending time.

  • A poll has ended and the results have been finalized.

This requires Intents.messages to be enabled.

Parameters:
  • before (Message) – The previous version of the message.

  • after (Message) – The current version of the message.

discord.on_raw_message_edit(payload)#

Called when a message is edited. Unlike on_message_edit(), this is called regardless of the state of the internal message cache.

If the message is found in the message cache, it can be accessed via RawMessageUpdateEvent.cached_message. The cached message represents the message before it has been edited. For example, if the content of a message is modified and triggers the on_raw_message_edit() coroutine, the RawMessageUpdateEvent.cached_message will return a Message object that represents the message before the content was modified.

Due to the inherently raw nature of this event, the data parameter coincides with the raw data given by the gateway.

Since the data payload can be partial, care must be taken when accessing stuff in the dictionary. One example of a common case of partial data is when the 'content' key is inaccessible. This denotes an “embed” only edit, which is an edit in which only the embeds are updated by the Discord embed server.

This requires Intents.messages to be enabled.

Parameters:

payload (RawMessageUpdateEvent) – The raw event payload data.

Polls#

discord.on_poll_vote_add(poll, user, answer)#

Called when a vote is cast on a poll. If multiple answers were selected, this fires multiple times. if the poll was not found in the internal poll cache, then this event will not be called. Consider using on_raw_poll_vote_add() instead.

This requires Intents.polls to be enabled.

Parameters:
  • poll (Poll) – The current state of the poll.

  • user (Union[Member, User]) – The user who added the vote.

  • answer (PollAnswer) – The answer that was voted.

discord.on_raw_poll_vote_add(payload)#

Called when a vote is cast on a poll. Unlike on_poll_vote_add(), this is called regardless of the state of the internal poll cache.

This requires Intents.polls to be enabled.

Parameters:

payload (RawMessagePollVoteEvent) – The raw event payload data.

discord.on_poll_vote_remove(message, user, answer)#

Called when a vote is removed from a poll. If multiple answers were removed, this fires multiple times. if the poll is not found in the internal poll cache, then this event will not be called. Consider using on_raw_poll_vote_remove() instead.

This requires Intents.polls to be enabled.

Parameters:
  • poll (Poll) – The current state of the poll.

  • user (Union[Member, User]) – The user who removed the vote.

  • answer (PollAnswer) – The answer that was voted.

discord.on_raw_poll_vote_remove(payload)#

Called when a vote is removed from a poll. Unlike on_poll_vote_remove(), this is called regardless of the state of the internal message cache.

This requires Intents.polls to be enabled.

Parameters:

payload (RawMessagePollVoteEvent) – The raw event payload data.

Reactions#

discord.on_reaction_add(reaction, user)#

Called when a message has a reaction added to it. Similar to on_message_edit(), if the message is not found in the internal message cache, then this event will not be called. Consider using on_raw_reaction_add() instead.

Note

To get the Message being reacted, access it via Reaction.message.

This requires Intents.reactions to be enabled.

Note

This doesn’t require Intents.members within a guild context, but due to Discord not providing updated user information in a direct message it’s required for direct messages to receive this event. Consider using on_raw_reaction_add() if you need this and do not otherwise want to enable the members intent.

Parameters:
  • reaction (Reaction) – The current state of the reaction.

  • user (Union[Member, User]) – The user who added the reaction.

discord.on_raw_reaction_add(payload)#

Called when a message has a reaction added. Unlike on_reaction_add(), this is called regardless of the state of the internal message cache.

This requires Intents.reactions to be enabled.

Parameters:

payload (RawReactionActionEvent) – The raw event payload data.

discord.on_reaction_remove(reaction, user)#

Called when a message has a reaction removed from it. Similar to on_message_edit, if the message is not found in the internal message cache, then this event will not be called.

Note

To get the message being reacted, access it via Reaction.message.

This requires both Intents.reactions and Intents.members to be enabled.

Note

Consider using on_raw_reaction_remove() if you need this and do not want to enable the members intent.

Parameters:
  • reaction (Reaction) – The current state of the reaction.

  • user (Union[Member, User]) – The user who added the reaction.

discord.on_raw_reaction_remove(payload)#

Called when a message has a reaction removed. Unlike on_reaction_remove(), this is called regardless of the state of the internal message cache.

This requires Intents.reactions to be enabled.

Parameters:

payload (RawReactionActionEvent) – The raw event payload data.

discord.on_reaction_clear(message, reactions)#

Called when a message has all its reactions removed from it. Similar to on_message_edit(), if the message is not found in the internal message cache, then this event will not be called. Consider using on_raw_reaction_clear() instead.

This requires Intents.reactions to be enabled.

Parameters:
  • message (Message) – The message that had its reactions cleared.

  • reactions (List[Reaction]) – The reactions that were removed.

discord.on_raw_reaction_clear(payload)#

Called when a message has all its reactions removed. Unlike on_reaction_clear(), this is called regardless of the state of the internal message cache.

This requires Intents.reactions to be enabled.

Parameters:

payload (RawReactionClearEvent) – The raw event payload data.

discord.on_reaction_clear_emoji(reaction)#

Called when a message has a specific reaction removed from it. Similar to on_message_edit(), if the message is not found in the internal message cache, then this event will not be called. Consider using on_raw_reaction_clear_emoji() instead.

This requires Intents.reactions to be enabled.

New in version 1.3.

Parameters:

reaction (Reaction) – The reaction that got cleared.

discord.on_raw_reaction_clear_emoji(payload)#

Called when a message has a specific reaction removed from it. Unlike on_reaction_clear_emoji() this is called regardless of the state of the internal message cache.

This requires Intents.reactions to be enabled.

New in version 1.3.

Parameters:

payload (RawReactionClearEmojiEvent) – The raw event payload data.

Scheduled Events#

discord.on_scheduled_event_create(event)#

Called when an ScheduledEvent is created.

This requires Intents.scheduled_events to be enabled.

Parameters:

event (ScheduledEvent) – The newly created scheduled event.

discord.on_scheduled_event_update(before, after)#

Called when a scheduled event is updated.

This requires Intents.scheduled_events to be enabled.

Parameters:
discord.on_scheduled_event_delete(event)#

Called when a scheduled event is deleted.

This requires Intents.scheduled_events to be enabled.

Parameters:

event (ScheduledEvent) – The deleted scheduled event.

discord.on_scheduled_event_user_add(event, member)#

Called when a user subscribes to an event. If the member or event is not found in the internal cache, then this event will not be called. Consider using on_raw_scheduled_event_user_add() instead.

This requires Intents.scheduled_events to be enabled.

Parameters:
  • event (ScheduledEvent) – The scheduled event subscribed to.

  • member (Member) – The member who subscribed.

discord.on_raw_scheduled_event_user_add(payload)#

Called when a user subscribes to an event. Unlike on_scheduled_event_user_add(), this will be called regardless of the state of the internal cache.

This requires Intents.scheduled_events to be enabled.

Parameters:

payload (RawScheduledEventSubscription) – The raw event payload data.

discord.on_scheduled_event_user_remove(event, member)#

Called when a user unsubscribes to an event. If the member or event is not found in the internal cache, then this event will not be called. Consider using on_raw_scheduled_event_user_remove() instead.

This requires Intents.scheduled_events to be enabled.

Parameters:
  • event (ScheduledEvent) – The scheduled event unsubscribed from.

  • member (Member) – The member who unsubscribed.

discord.on_raw_scheduled_event_user_remove(payload)#

Called when a user unsubscribes to an event. Unlike on_scheduled_event_user_remove(), this will be called regardless of the state of the internal cache.

This requires Intents.scheduled_events to be enabled.

Parameters:

payload (RawScheduledEventSubscription) – The raw event payload data.

Stage Instances#

discord.on_stage_instance_create(stage_instance)#
discord.on_stage_instance_delete(stage_instance)#

Called when a StageInstance is created or deleted for a StageChannel.

New in version 2.0.

Parameters:

stage_instance (StageInstance) – The stage instance that was created or deleted.

discord.on_stage_instance_update(before, after)#

Called when a StageInstance is updated.

The following, but not limited to, examples illustrate when this event is called:

  • The topic is changed.

  • The privacy level is changed.

New in version 2.0.

Parameters:

Threads#

discord.on_thread_join(thread)#

Called whenever a thread is joined.

Note that you can get the guild from Thread.guild.

This requires Intents.guilds to be enabled.

New in version 2.0.

Parameters:

thread (Thread) – The thread that got joined.

discord.on_thread_create(thread)#

Called whenever a thread is created.

Note that you can get the guild from Thread.guild.

This requires Intents.guilds to be enabled.

New in version 2.0.

Parameters:

thread (Thread) – The thread that got created.

discord.on_thread_remove(thread)#

Called whenever a thread is removed. This is different from a thread being deleted.

Note that you can get the guild from Thread.guild.

This requires Intents.guilds to be enabled.

Warning

Due to technical limitations, this event might not be called as soon as one expects. Since the library tracks thread membership locally, the API only sends updated thread membership status upon being synced by joining a thread.

New in version 2.0.

Parameters:

thread (Thread) – The thread that got removed.

discord.on_thread_delete(thread)#

Called whenever a thread is deleted. If the deleted thread isn’t found in internal cache then this will not be called. Archived threads are not in the cache. Consider using on_raw_thread_delete()

Note that you can get the guild from Thread.guild.

This requires Intents.guilds to be enabled.

New in version 2.0.

Parameters:

thread (Thread) – The thread that got deleted.

discord.on_raw_thread_delete(payload)#

Called whenever a thread is deleted. Unlike on_thread_delete() this is called regardless of the state of the internal cache.

Parameters:

payload (RawThreadDeleteEvent) – The raw event payload data.

discord.on_thread_member_join(member)#
discord.on_thread_member_remove(member)#

Called when a ThreadMember leaves or joins a Thread.

You can get the thread a member belongs in by accessing ThreadMember.thread.

This requires Intents.members to be enabled.

New in version 2.0.

Parameters:

member (ThreadMember) – The member who joined or left.

discord.on_raw_thread_member_remove(payload)#

Called when a ThreadMember leaves a Thread. Unlike on_thread_member_remove() this is called regardless of the member being in the thread’s internal cache of members or not.

This requires Intents.members to be enabled.

New in version 2.4.

Parameters:

payload – The raw event payload data.

discord.on_thread_update(before, after)#

Called whenever a thread is updated.

This requires Intents.guilds to be enabled.

If the thread could not be found in the internal cache, this event will not be called. Threads will not be in the cache if they are archived. Alternatively, on_raw_thread_update() is called regardless of the internal cache.

New in version 2.0.

Parameters:
  • before (Thread) – The updated thread’s old info.

  • after (Thread) – The updated thread’s new info.

discord.on_raw_thread_update(payload)#

Called whenever a thread is updated.

Unlike on_thread_update() this is called regardless of if the thread is in the internal thread cache or not.

This requires Intents.guilds to be enabled.

New in version 2.4.

Parameters:

payload (RawThreadUpdateEvent) – The raw event payload data.

Typing#

discord.on_typing(channel, user, when)#

Called when someone begins typing a message.

The channel parameter can be a abc.Messageable instance. Which could either be TextChannel, GroupChannel, or DMChannel.

If the channel is a TextChannel then the user parameter is a Member, otherwise it is a User.

This requires Intents.typing to be enabled.

Parameters:
  • channel (abc.Messageable) – The location where the typing originated from.

  • user (Union[User, Member]) – The user that started typing.

  • when (datetime.datetime) – When the typing started as an aware datetime in UTC.

discord.on_raw_typing(payload)#

Called when someone begins typing a message. Unlike on_typing(), this is called regardless if the user can be found in the bot’s cache or not.

If the typing event is occurring in a guild, the member that started typing can be accessed via RawTypingEvent.member

This requires Intents.typing to be enabled.

Parameters:

payload (RawTypingEvent) – The raw typing payload.

Voice Channel Status Update#

discord.on_voice_channel_status_update(channel, before, after)#

Called when someone updates a voice channel status.

New in version 2.5.

Parameters:
  • channel (abc.GuildChannel) – The channel where the voice channel status update originated from.

  • before (Optional[str]) – The old voice channel status.

  • after (Optional[str]) – The new voice channel status.

discord.on_raw_voice_channel_status_update(payload)#

Called when someone updates a voice channels status.

New in version 2.5.

Parameters:

payload (RawVoiceChannelStatusUpdateEvent) – The raw voice channel status update payload.