Skip to content

Instantly share code, notes, and snippets.

@Iliannnn
Last active October 19, 2023 23:59
Show Gist options
  • Save Iliannnn/6c69605cb6b8cc03f0ab9c885fd39906 to your computer and use it in GitHub Desktop.
Save Iliannnn/6c69605cb6b8cc03f0ab9c885fd39906 to your computer and use it in GitHub Desktop.
Discord.js v13 Events - Cheatsheet

Discord.js v13 Events

An overview of all events in Discord.js v13 with examples.

๐Ÿ“ข | Last updated: 27 July 2022

โ„น๏ธ | client references to your client instance.

โ„น๏ธ | The v14 overview can be found here.

Events

List of events in this overview

apiRequest

Emitted before every API request. This event can emit several times for the same request, e.g. when hitting a rate limit.

Parameter Type Description
request APIRequest The request that is about to be send
client.on('apiRequest', (request) => {
    console.log(`apiRequest: ${request}`);
});

apiResponse

Emitted after every API request has received a response. This event does not necessarily correlate to completion of the request, e.g. when hitting a rate limit.

Parameter Type Description
request APIRequest The request that is about to be send
response Response The response received from the Discord API
client.on('apiResponse', (request, response) => {
    console.log(`apiResponse: ${request} | ${response}`);
});

applicationCommandCreate

โš ๏ธ | This event is deprecated, see this issue for more information.

Emitted when a guild application command is created.

Parameter Type Description
command ApplicationCommand The command which was created
client.on('applicationCommandCreate', (command) => {
    console.log(`applicationCommandCreate: ${command}`);
});

applicationCommandDelete

โš ๏ธ | This event is deprecated, see this issue for more information.

Emitted when a guild application command is deleted.

Parameter Type Description
command ApplicationCommand The command which was deleted
client.on('applicationCommandDelete', (command) => {
    console.log(`applicationCommandDelete: ${command}`);
});

applicationCommandUpdate

โš ๏ธ | This event is deprecated, see this issue for more information.

Emitted when a guild application command is updated.

Parameter Type Description
oldCommand ?ApplicationCommand The command before the update
newCommand ApplicationCommand The command after the update
client.on('applicationCommandUpdated', (oldCommand, newCommand) => {
    console.log(`applicationCommandUpdated: ${oldCommand} | ${newCommand}`);
});

channelCreate

Emitted whenever a guild channel is created.

Parameter Type Description
channel GuildChannel The channel that was created
client.on('channelCreate', (channel) => {
    console.log(`channelCreate: ${channel}`);
});

channelDelete

Emitted whenever a channel is deleted.

Parameter Type Description
channel DMChannel or GuildChannel The channel that was deleted
client.on('channelDelete', (channel) => {
    console.log(`channelDelete: ${channel}`);
});

channelPinsUpdate

Emitted whenever the pins of a channel are updated. Due to the nature of the WebSocket event, not much information can be provided easily here - you need to manually check the pins yourself.

Parameter Type Description
channel TextBasedChannels The channel that the pins update occurred in
time Date The time of the pins update
client.on('channelPinsUpdate', (channel, time) => {
    console.log(`channelPinsUpdate: ${channel} | ${time}`);
});

channelUpdate

Emitted whenever a channel is updated - e.g. name change, topic change, channel type change.

Parameter Type Description
oldChannel DMChannel or GuildChannel The channel before the update
newChannel DMChannel or GuildChannel The channel after the update
client.on('channelUpdate', (oldChannel, newChannel) => {
    console.log(`channelUpdate: ${oldChannel} | ${newChannel}`);
});

debug

Emitted for general debugging information.

Parameter Type Description
info string The debug info
client.on('debug', (debug) => {
    console.log(`debug: ${info}`);
});

emojiCreate

Emitted whenever a custom emoji is created in a guild.

Parameter Type Description
emoji GuildEmoji The emoji that was created
client.on('emojiCreate', (emoji) => {
    console.log(`emojiCreate: ${emoji}`);
});

emojiDelete

Emitted whenever a custom emoji is deleted in a guild.

Parameter Type Description
emoji GuildEmoji The emoji that was deleted
client.on('emojiDelete', (emoji) => {
    console.log(`emojiDelete: ${emoji}`);
});

emojiUpdate

Emitted whenever a custom emoji is updated in a guild.

Parameter Type Description
oldEmoji GuildEmoji The old emoji
newEmoji GuildEmoji The new emoji
client.on('emojiUpdate', (oldEmoji, newEmoji) => {
    console.log(`emojiUpdate: ${oldEmoji} | ${newEmoji}`);
});

error

Emitted when the client encounters an error.

Parameter Type Description
error error The error that encountered
client.on('error', (error) => {
    console.log(`error: ${error}`);
});

guildBanAdd

Emitted whenever a member is banned from a guild.

Parameter Type Description
ban guildBan The ban that occurred
client.on('guildBanAdd', (ban) => {
    console.log(`guildBanAdd: ${ban}`);
});

guildBanRemove

Emitted whenever a member is unbanned from a guild.

Parameter Type Description
ban guildBan The ban that was removed
client.on('guildBanRemove', (ban) => {
    console.log(`guildBanRemove: ${ban}`);
});

guildCreate

Emitted whenever the client joins a guild.

Parameter Type Description
guild Guild The created guild
client.on('guildCreate', (guild) => {
    console.log(`guildCreate: ${guild}`);
});

guildDelete

Emitted whenever a guild kicks the client or the guild is deleted/left.

Parameter Type Description
guild Guild The guild that was deleted
client.on('guildDelete', (guild) => {
    console.log(`guildDelete: ${guild}`);
});

guildIntegrationsUpdate

Emitted whenever a guild integration is updated.

Parameter Type Description
guild Guild The guild whose integrations were updated
client.on('guildIntegrationsUpdate', (guild) => {
    console.log(`guildIntegrationsUpdate: ${guild}`);
});

guildMemberAdd

Emitted whenever a user joins a guild.

Parameter Type Description
member GuildMember The member that has joined a guild
client.on('guildMemberAdd', (member) => {
    console.log(`guildMemberAdd: ${member}`);
});

guildMemberAvailable

Emitted whenever a member becomes available in a large guild.

Parameter Type Description
member GuildMember The member that became available
client.on('guildMemberAvailable', (member) => {
    console.log(`guildMemberAvailable: ${member}`);
});

guildMemberRemove

Emitted whenever a member leaves a guild, or is kicked.

Parameter Type Description
member GuildMember The member that has left/been kicked from the guild
client.on('guildMemberRemove', (member) => {
    console.log(`guildMemberRemove: ${member}`);
});

guildMembersChunk

Emitted whenever a chunk of guild members is received (all members come from the same guild).

Parameter Type Description
members Collection<Snowflake, GuildMember> The members in the chunk
guild Guild The guild related to the member chunk
chunk GuildMembersChunk Properties of the received chunk
client.on('guildMembersChunk', (members, guild, chunk) => {
    console.log(`guildMemberRemove: ${members} | ${guild} | ${chunk}`);
});

guildMemberUpdate

Emitted whenever a guild member changes - i.e. new role, removed role, nickname.

Parameter Type Description
oldMember GuildMember The member before the update
newMember GuildMember The member after the update
client.on('guildMemberUpdate', (oldMember) => {
    console.log(`guildMemberUpdate: ${oldMember} | ${newMember}`);
});

guildScheduledEventCreate

Emitted whenever a guild scheduled event is created.

Parameter Type Description
guildScheduledEvent GuildScheduledEvent The created guild scheduled event
client.on('guildScheduledEventCreate', (guild) => {
    console.log(`guildScheduledEventCreate: ${guildScheduledEvent}`);
});

guildScheduledEventDelete

Emitted whenever a guild scheduled event is created.

Parameter Type Description
guildScheduledEvent GuildScheduledEvent The deleted guild scheduled event
client.on('guildScheduledEventCreate', (guild) => {
    console.log(`guildScheduledEventCreate: ${guildScheduledEvent}`);
});

guildScheduledEventUpdate

Emitted whenever a guild scheduled event gets updated.

Parameter Type Description
oldGuildScheduledEvent GuildScheduledEvent The guild scheduled event object before the update
newGuildScheduledEvent GuildScheduledEvent The guild scheduled event object after the update
client.on('guildScheduledEventUpdate', (guild) => {
    console.log(`guildScheduledEventUpdate: ${oldGuildScheduledEvent} | ${newGuildScheduledEvent}`);
});

guildScheduledEventUserAdd

Emitted whenever a user subscribes to a guild scheduled event

Parameter Type Description
guildScheduledEvent GuildScheduledEvent The guild scheduled event
user User The user who subscribed
client.on('guildScheduledEventUserAdd', (guild) => {
    console.log(`guildScheduledEventUserAdd: ${guildScheduledEvent} | ${user}`);
});

guildScheduledEventUserRemove

Emitted whenever a user unsubscribes from a guild scheduled event

Parameter Type Description
guildScheduledEvent GuildScheduledEvent The guild scheduled event
user User The user who unsubscribed
client.on('guildScheduledEventUserRemove', (guild) => {
    console.log(`guildScheduledEventUserRemove: ${guildScheduledEvent} | ${user}`);
});

guildUnavailable

Emitted whenever a guild becomes unavailable, likely due to a server outage.

Parameter Type Description
guild Guild The guild that has become unavailable
client.on('guildUnavailable', (guild) => {
    console.log(`guildUnavailable: ${guild}`);
});

guildUpdate

Emitted whenever a guild is updated - e.g. name change.

Parameter Type Description
oldGuild Guild The guild before the update
newGuild Guild The guild after the update
client.on('guildUpdate', (oldGuild, newGuild) => {
    console.log(`guildUpdate: ${oldGuild} | ${newGuild}`);
});

interaction

โš ๏ธ | This event is deprecated, use interactionCreate instead.

Emitted when an interaction is created.

Parameter Type Description
interaction Interaction The interaction which was created
client.on('interaction', (interaction) => {
    console.log(`interaction: ${interaction}`);
});

interactionCreate

Emitted when an interaction is created.

Parameter Type Description
interaction Interaction The interaction which was created
client.on('interactionCreate', (interaction) => {
    console.log(`interactionCreate: ${interaction}`);
});

invalidated

Emitted when the client's session becomes invalidated. You are expected to handle closing the process gracefully and preventing a boot loop if you are listening to this event.

client.on('invalidated', () => {
    console.log(`invalidated`);
});

invalidRequestWarning

Emitted periodically when the process sends invalid requests to let users avoid the 10k invalid requests in 10 minutes threshold that causes a ban.

Parameter Type Description
invalidRequestWarningData invalidRequestWarningData Object containing the invalid request info
client.on('invalidRequestWarning', (invalidRequestWarningData) => {
    console.log(`invalidRequestWarning: ${invalidRequestWarningData}`);
});

inviteCreate

โ„น๏ธ | This event only triggers if the client has MANAGE_GUILD permissions for the guild, or MANAGE_CHANNELS permissions for the channel.

Emitted when an invite is created.

Parameter Type Description
invite Invite The invite that was created
client.on('inviteCreate', (invite) => {
    console.log(`inviteCreate: ${invite}`);
});

inviteDelete

โ„น๏ธ | This event only triggers if the client has MANAGE_GUILD permissions for the guild, or MANAGE_CHANNELS permissions for the channel.

Emitted when an invite is deleted.

Parameter Type Description
invite Invite The invite that was deleted
client.on('inviteDelete', (invite) => {
    console.log(`inviteDelete: ${invite}`);
});

message

โš ๏ธ | This event is deprecated, use messageCreate instead.

Emitted when a message is created.

Parameter Type Description
message Message The created message
client.on('message', (message) => {
    console.log(`message: ${message}`);
});

messageCreate

Emitted when a message is created.

Parameter Type Description
message Message The created message
client.on('messageCreate', (message) => {
    console.log(`messageCreate: ${message}`);
});

messageDelete

Emitted whenever a message is deleted.

Parameter Type Description
message Message The deleted message
client.on('messageDelete', (message) => {
    console.log(`messageDelete: ${message}`);
});

messageDeleteBulk

Emitted whenever messages are deleted in bulk.

Parameter Type Description
messages Collection<Snowflake, Message> The deleted messages, mapped by their id
client.on('messageDeleteBulk', (messages) => {
    console.log(`messageDeleteBulk: ${messages}`);
});

messageReactionAdd

Emitted whenever a reaction is added to a cached message.

Parameter Type Description
messageReaction MessageReaction The reaction object
user User The user that applied the guild or reaction emoji
client.on('messageReactionAdd', (reaction, user) => {
    console.log(`messageReactionAdd: ${reaction} | ${user}`);
});

messageReactionRemove

Emitted whenever a reaction is removed from a cached message.

Parameter Type Description
messageReaction MessageReaction The reaction object
user User The user whose emoji or reaction emoji was removed
client.on('messageReactionRemove', (reaction, user) => {
    console.log(`messageReactionRemove: ${reaction} | ${user}`);
});

messageReactionRemoveAll

Emitted whenever all reactions are removed from a cached message.

Parameter Type Description
message Message The message the reactions were removed from
reactions Collection<string | Snowflake, MessageReaction> The cached message reactions that were removed
client.on('messageReactionRemoveAll', (message, reactions) => {
    console.log(`messageReactionRemoveAll: ${message} | ${reactions}`);
});

messageReactionRemoveEmoji

Emitted when a bot removes an emoji reaction from a cached message.

Parameter Type Description
reaction MessageReaction The reaction that was removed
client.on('messageReactionRemoveEmoji', (reaction) => {
    console.log(`messageReactionRemoveEmoji: ${reaction}`);
});

messageUpdate

Emitted whenever a message is updated - e.g. embed or content change.

Parameter Type Description
oldMessage Message The message before the update
newMessage Message The message after the update
client.on('messageUpdate', (oldMessage, newMessage) => {
    console.log(`messageUpdate: ${oldMessage} | ${newMessage}`);
});

presenceUpdate

Emitted whenever a guild member's presence (e.g. status, activity) is changed.

Parameter Type Description
oldPresence ?Presence The presence before the update, if one at all
newPresence Presence The presence after the update
client.on('presenceUpdate', (oldPresence, newPresence) => {
    console.log(`presenceUpdate: ${oldPresence} | ${newPresence}`);
});

rateLimit

Emitted when the client hits a rate limit while making a request.

Parameter Type Description
rateLimitData RateLimitData Object containing the rate limit info
client.on('rateLimit', (rateLimitData) => {
    console.log(`rateLimit: ${rateLimitData}`);
});

ready

Emitted when the client becomes ready to start working.

Parameter Type Description
client Client The client
client.on('ready', (client) => {
    console.log(`ready: ${client}`);
});

roleCreate

Emitted whenever a role is created.

Parameter Type Description
role Role The role that was created
client.on('roleCreate', (role) => {
    console.log(`roleCreate: ${role}`);
});

roleDelete

Emitted whenever a role is deleted.

Parameter Type Description
role Role The role that was deleted
client.on('roleDelete', (role) => {
    console.log(`roleDelete: ${role}`);
});

roleUpdate

Emitted whenever a role is updated.

Parameter Type Description
oldRole Role The role before the update
newRole Role The role after the update
client.on('roleUpdate', (oldRole, newRole) => {
    console.log(`roleUpdate: ${oldRole} | ${newRole}`);
});

shardDisconnect

Emitted when a shard's WebSocket disconnects and will no longer reconnect.

Parameter Type Description
event CloseEvent The WebSocket cloes event
id number The shard id that disconnected
client.on('shardDisconnect', (event, id) => {
    console.log(`shardDisconnect: ${event} | ${id}`);
});

shardError

Emitted whenever a shard's WebSocket encounters a connection error.

Parameter Type Description
error Error The encountered error
shardId number The shard that encountered this error
client.on('shardError', (error, shardId) => {
    console.log(`shardError: ${error} | ${shardId}`);
});

shardReady

Emitted when a shard turns ready.

Parameter Type Description
id number The shard id that turned ready
unavailableGuilds ?Set<Snowflake> Set of unavailable guild ids, if any
client.on('shardReady', (id, unavailableGuilds) => {
    console.log(`shardError: ${id} | ${unavailableGuilds}`);
});

shardReconnecting

Emitted when a shard is attempting to reconnect or re-identify.

Parameter Type Description
id number The shard id that is attempting to reconnect
client.on('shardReconnecting', (id) => {
    console.log(`shardReconnecting: ${id}`);
});

shardResume

Emitted when a shard resumes successfully.

Parameter Type Description
id number The shard id that resumed
replayedEvents number The amount of replayed events
client.on('shardResume', (id, replayedEvents) => {
    console.log(`shardReconnecting: ${id} | ${replayedEvents}`);
});

stageInstanceCreate

Emitted whenever a stage instance is created.

Parameter Type Description
stageInstance StageInstance The created stage instance
client.on('stageInstanceCreate', (stageInstance) => {
    console.log(`stageInstanceCreate: ${stageInstance}`);
});

stageInstanceDelete

Emitted whenever a stage instance is deleted.

Parameter Type Description
stageInstance StageInstance The deleted stage instance
client.on('stageInstanceDelete', (stageInstance) => {
    console.log(`stageInstanceDelete: ${stageInstance}`);
});

stageInstanceUpdate

Emitted whenever a stage instance gets updated - e.g. change in topic or privacy level.

Parameter Type Description
oldStageInstance ?StageInstance The stage instance before the update
newStageInstance StageInstance The stage instance after the update
client.on('stageInstanceUpdate', (oldStageInstance, newStageInstance) => {
    console.log(`stageInstanceUpdate: ${oldStageInstance} | ${newStageInstance}`);
});

stickerCreate

Emitted whenever a custom sticker is created in a guild.

Parameter Type Description
sticker Sticker The sticker that was created
client.on('stickerCreate', (sticker) => {
    console.log(`stickerCreate: ${sticker}`);
});

stickerDelete

Emitted whenever a custom sticker is deleted in a guild.

Parameter Type Description
sticker Sticker The sticker that was deleted
client.on('stickerDelete', (sticker) => {
    console.log(`stickerDelete: ${sticker}`);
});

stickerUpdate

Emitted whenever a custom sticker is deleted in a guild.

Parameter Type Description
oldSticker Sticker The old sticker
newSticker Sticker The new sticker
client.on('stickerUpdate', (oldSticker, newSticker) => {
    console.log(`stickerUpdate: ${oldSticker} | ${newSticker}`);
});

threadCreate

Emitted whenever a thread is created or when the client user is added to a thread.

Parameter Type Description
thread ThreadChannel The thread that was created
client.on('threadCreate', (thread) => {
    console.log(`threadCreate: ${thread}`);
});

threadDelete

Emitted whenever a thread is created or when the client user is added to a thread.

Parameter Type Description
thread ThreadChannel The thread that was deleted
client.on('threadDelete', (thread) => {
    console.log(`threadDelete: ${thread}`);
});

threadListSync

Emitted whenever the client user gains access to a text or news channel that contains threads

Parameter Type Description
threads Collection<Snowflake, ThreadChannel> The threads that were synced
client.on('threadListSync', (threads) => {
    console.log(`threadListSync: ${threads}`);
});

threadMembersUpdate

Emitted whenever members are added or removed from a thread.

Parameter Type Description
oldMembers Collection<Snowflake, ThreadMember> The members before the update
newMembers Collection<Snowflake, ThreadMember> The members after the update
client.on('threadMembersUpdate', (oldMembers, newMembers) => {
    console.log(`threadMembersUpdate: ${oldMembers} | ${newMembers}`);
});

threadMemberUpdate

Emitted whenever the client user's thread member is updated.

Parameter Type Description
oldMember ThreadMember The member before the update
newMember ThreadMember The member after the update
client.on('threadMemberUpdate', (oldMember, newMember) => {
    console.log(`threadMemberUpdate: ${oldMember} | ${newMember}`);
});

threadUpdate

Emitted whenever a thread is updated - e.g. name change, archive state change, locked state change.

Parameter Type Description
oldThread ThreadChannel The thread before the update
newThread ThreadChannel The thread after the update
client.on('threadUpdate', (oldThread, newThread) => {
    console.log(`threadUpdate: ${oldThread} | ${newThread}`);
});

typingStart

Emitted whenever a user starts typing in a channel.

Parameter Type Description
typing Typing The typing state
client.on('typingStart', (typing) => {
    console.log(`typingStart: ${typing}`);
});

userUpdate

โ„น๏ธ | Triggered by the Discord gateway events USER_UPDATE, GUILD_MEMBER_UPDATE, and PRESENCE_UPDATE.

Emitted whenever a user's details (e.g. username) are changed.

Parameter Type Description
oldUser User The user before the update
newUser User The user after the update
client.on('userUpdate', (oldUser, newUser) => {
    console.log(`userUpdate: ${oldUser} | ${newUser}`);
});

voiceStateUpdate

Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.

Parameter Type Description
oldState VoiceState The voice state before the update
newState VoiceState The voice state after the update
client.on('voiceStateUpdate', (oldUser, newUser) => {
    console.log(`voiceStateUpdate: ${oldState} | ${newState}`);
});

warn

Emitted for general warnings.

Parameter Type Description
info string The warning
client.on('warn', (info) => {
    console.log(`warn: ${info}`);
});

webhookUpdate

Emitted whenever a channel has its webhooks changed.

Parameter Type Description
channel TextChannel or NewsChannel or VoiceChannel The channel that had a webhook update
client.on('webhookUpdate', (channel) => {
    console.log(`webhookUpdate: ${channel}`);
});
@Iliannnn
Copy link
Author

Thanks bro

its helped me for creating logger

Thank you for the feedback ๐Ÿ‘

@rasil859
Copy link

thank you so much bro!

@Iliannnn
Copy link
Author

thank you so much bro!

No problem!

@oklahomadev
Copy link

ty this will be good for my self event logger when i will want to add more ๐Ÿ‘

@Iliannnn
Copy link
Author

ty this will be good for my self event logger when i will want to add more ๐Ÿ‘

Goodluck

@RJRYT
Copy link

RJRYT commented Aug 15, 2023

Thanks bro
its helped me for creating logger

Thank you for the feedback ๐Ÿ‘

Yeah welcome ๐Ÿ˜€

@oklahomadev
Copy link

ty this will be good for my self event logger when i will want to add more ๐Ÿ‘

Goodluck

ty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment