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:

userUser 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:

pingPing 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:

datadict 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 (listener)

Using this event will disable the default ERROR print given by the library, and instead let you decide what it should do.

Parameters:
  • clientClient The client object.

  • errorException 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:
  • ctxContext The context object.

  • errorException object with the error that occurred.

Gateway events

Note

These events are only provided if discord.http/gateway is enabled.

from discord_http import Client
from discord_http.gateway import Intents

client = Client(
    ...,
    enable_gateway=True,
    # intents=Intents
)

Shard events

Note

These events are only provided if discord.http/gateway is enabled. By default if the gateway is enabled, they will do [  INFO ] logs. You can in theory listen to the events and simply do nothing to disable the logs.

async def on_shard_ready(shard):

Called whenever a shard is now ready

Parameters:

shardShard object with information about the shard.

async def on_shard_resumed(shard):

Called whenever a shard is resumed

Parameters:

shardShard object with information about the shard.

async def on_shard_closed(shard, close_type):

Called whenever a shard is closed

Parameters:
  • shardShard object with information about the shard.

  • close_typeShardCloseType object with information about the shard close type.

Intents.guilds

async def on_guild_create(guild):

Called whenever a guild is created (Bot was added)

Note

This event is not called unless the shard is ready, to prevent spam.

Parameters:

guildGuild object with information about the guild.

async def on_guild_update(guild):

Called whenever a guild is updated.

Parameters:

guildGuild object with information about the guild.

async def on_guild_delete(guild):

Called whenever a guild is deleted (Bot was removed)

Note

Depending on your cache rules, Guild will either return Full or Partial object.

Parameters:

guildPartialGuild object with information about the guild.

async def on_guild_available(guild):

Called whenever a guild was initially created, but came back from unavailable state

Note

Depending on your cache rules, Guild will either return Full or Partial object.

Parameters:

guildGuild object with information about that guild

async def on_guild_unavailable(guild):

Called whenever a guild is deleted, but came back from available state

Note

Depending on your cache rules, Guild will either return Full or Partial object.

Parameters:

guildGuild object with information about that guild

async def on_guild_role_create(role):

Called whenever a role was created

Note

Depending on your cache rules, Role.guild will either return Full or Partial object.

Parameters:

roleRole object with information about the role.

async def on_guild_role_update(role):

Called whenever a role was updated

Note

Depending on your cache rules, Role.guild will either return Full or Partial object.

Parameters:

roleRole object with information about the role.

async def on_guild_role_delete(role):

Called whenever a role was deleted

Parameters:

rolePartialRole object with information about the role.

async def on_channel_create(channel):

Called whenever a channel is created

Note

Depending on what channel was made, it will either return TextChannel, VoiceChannel, etc.

Parameters:

channelBaseChannel object with information about the channel.

async def on_channel_update(channel):

Called whenever a channel is updated

Parameters:

channelBaseChannel object with information about the channel.

async def on_channel_delete(channel):

Called whenever a channel is deleted

Parameters:

channelBaseChannel object with information about the channel.

async def on_channel_pins_update(payload):

Called whenever a channel’s pins are updated

Parameters:

payloadChannelPinsUpdate object with information about the pins.

async def on_thread_create(thread):

Called whenever a thread is created

Note

Depending on what type of thread was made, it will either return PublicThread, PrivateThread, etc.

Parameters:

threadBaseChannel object with information about the thread.

async def on_thread_update(thread):

Called whenever a thread is updated

Note

Depending on what type of thread was updated, it will either return PublicThread, PrivateThread, etc.

Parameters:

threadBaseChannel object with information about the thread.

async def on_thread_delete(thread):

Called whenever a thread is deleted

Parameters:

threadPartialChannel object with information about the thread.

async def on_thread_list_sync(payload):

Called whenever a thread list is synced

Parameters:

payloadThreadListSyncPayload object with information about the thread list.

async def on_thread_member_update(payload):

Called whenever a thread member is updated

Parameters:

payloadThreadMembersUpdatePayload object with information about the thread member.

async def on_thread_members_update(payload):

Called whenever a thread members are updated

Parameters:

payloadThreadMembersUpdatePayload object with information about the thread members.

async def on_stage_instance_create(stage_instance):

Called whenever a stage instance is created

Note

Depending on your cache rules, StageInstance.guild will either return Full or Partial object.

Parameters:

stage_instanceStageInstance object with information about the stage instance.

async def on_stage_instance_update(stage_instance):

Called whenever a stage instance is updated

Note

Depending on your cache rules, StageInstance.guild will either return Full or Partial object.

Parameters:

stage_instanceStageInstance object with information about the stage instance.

async def on_stage_instance_delete(stage_instance):

Called whenever a stage instance is deleted

Note

Depending on your cache rules, StageInstance.guild will either return Full or Partial object.

Parameters:

stage_instancePartialStageInstance object with information about the stage instance.

Intents.guild_members

async def on_guild_member_add(guild, member):

Called whenever a member joins a guild

Note

Depending on your cache rules, Member.guild and guild will either return Full or Partial object.

Parameters:
  • guildGuild | PartialGuild object with information about the guild.

  • memberMember object with information about the member.

async def on_guild_member_update(guild, member):

Called whenever a member is updated

Note

Depending on your cache rules, Member.guild and guild will either return Full or Partial object.

Parameters:
  • guildGuild | PartialGuild object with information about the guild.

  • memberMember object with information about the member.

async def on_guild_member_remove(guild, member):

Called whenever a member leaves a guild

Note

Depending on your cache rules, guild will either return Full or Partial object.

Parameters:
  • guildGuild | PartialGuild object with information about the guild.

  • memberUser object with information about the member.

async def on_thread_members_update(payload):

Called whenever a thread members are updated

Note

Depending on your cache rules, ThreadMember.guild will either return Full or Partial object.

Parameters:

payloadThreadMembersUpdatePayload object with information about the thread members.

Intents.guild_moderation

async def on_guild_audit_log_entry_create(entry):

Called whenever an audit log entry is created

Note

Depending on your cache rules, AuditLogEntry.guild will either return Full or Partial object.

Parameters:

entryAuditLogEntry object with information about the audit log entry.

async def on_guild_ban_add(guild, user):

Called whenever a user is banned from a guild

Note

Depending on your cache rules, guild will either return Full or Partial object.

Parameters:
  • guildGuild | PartialGuild object with information about the guild.

  • userUser object with information about the user.

async def on_guild_ban_remove(guild, user):

Called whenever a user is unbanned from a guild

Note

Depending on your cache rules, guild will either return Full or Partial object.

Parameters:
  • guildGuild | PartialGuild object with information about the guild.

  • userUser object with information about the user.

Intents.guild_expressions

async def on_guild_emojis_update(guild, before, after):

Called whenever guild emojis have been updated

Warning

The before will remain the same as after unless you have Guild and Emoji cache flags enabled (not partial).

Parameters:
  • guildGuild | PartialGuild object with information about the guild.

  • before – list[Emoji] emojis before the update.

  • after – list[Emoji] emojis after the update.

async def on_guild_stickers_update(guild, before, after):

Called whenever guild stickers have been updated

Warning

The before will remain the same as after unless you have Guild and Sticker cache flags enabled (not partial).

Parameters:
  • guildGuild | PartialGuild object with information about the guild.

  • before – list[Sticker] stickers before the update.

  • after – list[Sticker] stickers after the update.

async def on_guild_soundboard_sound_create(sound):

Called whenever a soundboard sound is created

Note

Depending on your cache rules, SoundboardSound.guild will either return Full or Partial object.

Parameters:

soundSoundboardSound object with information about the soundboard sound.

async def on_guild_soundboard_sound_update(sound):

Called whenever a soundboard sound is updated

Note

Depending on your cache rules, SoundboardSound.guild will either return Full or Partial object.

Parameters:

soundSoundboardSound object with information about the soundboard sound.

async def on_guild_soundboard_sound_delete(sound):

Called whenever a soundboard sound is deleted

Note

Depending on your cache rules, SoundboardSound.guild will either return Full or Partial object.

Parameters:

soundSoundboardSound object with information about the soundboard sound.

async def on_guild_soundboard_sounds_update(sounds):

Called whenever a soundboard sounds are updated

Note

Depending on your cache rules, sounds[].guild will either return Full or Partial object.

Parameters:

sounds – list[SoundboardSound] object with information about the soundboard sounds.

Intents.guild_integrations

async def on_guild_integrations_update(guild):

Called whenever a guild integration is updated

Note

Depending on your cache rules, guild will either return Full or Partial object.

Parameters:

guildGuild | PartialGuild object with information about the guild.

async def on_integration_create(integration):

Called whenever an integration is created

Note

Depending on your cache rules, Integration.guild will either return Full or Partial object.

Parameters:

integrationIntegration object with information about the integration.

async def on_integration_update(integration):

Called whenever an integration is updated

Note

Depending on your cache rules, Integration.guild will either return Full or Partial object.

Parameters:

integrationIntegration object with information about the integration.

async def on_integration_delete(integration):

Called whenever an integration is deleted

Parameters:

integrationPartialIntegration object with information about the integration.

Intents.guild_webhooks

async def on_webhooks_update(channel):

Called whenever a webhook is updated

Note

Depending on your cache rules, channel will either return TextChannel/VoiceChannel/etc. or Partial object.

Parameters:

channelPartialChannel | BaseChannel* object with information about the channel.

Intents.guild_invites

async def on_invite_create(invite):

Called whenever an invite is created

Parameters:

inviteInvite object with information about the invite.

async def on_invite_delete(invite):

Called whenever an invite is deleted

Parameters:

invitePartialInvite object with information about the invite.

Intents.guild_voice_states

async def on_voice_state_update(before_voice, after_voice):

Called whenever a voice state is updated

Note

Depending on your cache rules, before_voice will either return Full, Partial object or None.

Parameters:
  • before_voiceVoiceState object with information about the new voice state.

  • after_voiceVoiceState object with information about the new voice state.

Intents.guild_presences

async def on_presence_update(presence):

Called whenever a presence is updated

Note

Depending on your cache rules, Presence.guild and Presence.user will either return Full or Partial object.

Parameters:

presencePresence object with information about the presence.

Intents.guild_messages

Note

Message.content will only return something if you have enabled Intents.message_content.

async def on_message_create(message):

Called whenever a message is created

Parameters:

messageMessage object with information about the message.

async def on_message_update(message):

Called whenever a message is updated

Parameters:

messageMessage object with information about the message.

async def on_message_delete(message):

Called whenever a message is deleted

Parameters:

messagePartialMessage object with information about the message.

async def on_message_delete_bulk(payload):

Called whenever a message is deleted in bulk

Note

Depending on your cache rules, payload.guild will either return Full or Partial object.

Parameters:

payloadBulkDeletePayload object with information about the message.

Intents.direct_messages

Same as Intents.guild_messages

Intents.guild_message_reactions

async def on_message_reaction_add(reaction):

Called whenever a message reaction is added

Parameters:

reactionReaction object with information about the reaction.

async def on_message_reaction_remove(reaction):

Called whenever a message reaction is removed

Parameters:

reactionReaction object with information about the reaction.

async def on_message_reaction_remove_all(message):

Called whenever all message reactions are removed

Parameters:

reactionPartialMessage object with information about the message.

async def on_message_reaction_remove_emoji(message, emoji):

Called whenever a message reaction is removed by an emoji

Parameters:
  • reactionPartialMessage object with information about the message.

  • emojiEmojiParser object with information about the emoji.

Intents.direct_message_reactions

Same as Intents.guild_message_reactions

Intents.guild_message_typing

async def on_typing_start(typing):

Called whenever a user starts typing

Note

Depending on your cache rules, typing.guild, typing.channel and typing.user will either return Full or Partial object.

Parameters:

typingTypingStartEvent object with information about the typing.

Intents.direct_message_typing

Same as Intents.guild_message_typing

Intents.guild_scheduled_events

async def on_guild_scheduled_event_create(event):

Called whenever a guild scheduled event is created

Parameters:

eventScheduledEvent object with information about the scheduled event.

async def on_guild_scheduled_event_update(event):

Called whenever a guild scheduled event is updated

Parameters:

eventScheduledEvent object with information about the scheduled event.

async def on_guild_scheduled_event_delete(event):

Called whenever a guild scheduled event is deleted

Parameters:

eventPartialScheduledEvent object with information about the scheduled event.

async def on_guild_scheduled_event_user_add(event, member):

Called whenever a user is added to a guild scheduled event

Note

Depending on your cache rules, member will either return Full or Partial object.

Parameters:
  • eventScheduledEvent object with information about the scheduled event.

  • memberPartialMember | Member object with information about the member.

async def on_guild_scheduled_event_user_remove(event, member):

Called whenever a user is removed from a guild scheduled event

Note

Depending on your cache rules, member will either return Full or Partial object.

Parameters:
  • eventScheduledEvent object with information about the scheduled event.

  • memberPartialMember | Member object with information about the member.

Intents.auto_moderation_configuration

async def on_auto_moderation_rule_create(rule):

Called whenever an automod rule is created

Parameters:

ruleAutoModRule object with information about the automod rule.

async def on_auto_moderation_rule_update(rule):

Called whenever an automod rule is updated

Parameters:

ruleAutoModRule object with information about the automod rule.

async def on_auto_moderation_rule_delete(rule):

Called whenever an automod rule is deleted

Parameters:

rulePartialAutoModRule object with information about the automod rule.

Intents.auto_moderation_execution

async def on_auto_moderation_action_execution(execution):

Called whenever an automod action is executed

Parameters:

executionAutomodExecution object with information about the automod rule.

Intents.guild_message_polls

async def on_message_poll_vote_add(vote):

Called whenever a message poll vote is added

Note

Depending on your cache rules, vote.guild, vote.channel and vote.user will either return Full or Partial object.

Parameters:

votePollVoteEvent object with information about the poll vote.

async def on_message_poll_vote_remove(vote):

Called whenever a message poll vote is removed

Note

Depending on your cache rules, vote.guild, vote.channel and vote.user will either return Full or Partial object.

Parameters:

votePollVoteEvent object with information about the poll vote.

Intents.direct_message_polls

Same as Intents.guild_message_polls