Skip to content

Instantly share code, notes, and snippets.

@soleroks
Forked from Iliannnn/Discord.js-v14-Events.md
Created August 22, 2024 20:13
Show Gist options
  • Save soleroks/efedeb70d372f506ea11832049294685 to your computer and use it in GitHub Desktop.
Save soleroks/efedeb70d372f506ea11832049294685 to your computer and use it in GitHub Desktop.
Discord.js v14 Events - Cheatsheet

Discord.js v14 Events

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

📢 | Last updated: 27 July 2022

ℹ️ | client references to your client instance.

ℹ️ | The v13 overview can be found here.

Events

List of events in this overview

applicationCommandPermissionsUpdate

⚠️ | This includes permission updates for other applications in addition to the logged in client, check data.applicationId to verify which application the update is for

Emitted whenever permissions for an application command in a guild were updated.

Parameter Type Description
data ApplicationCommandPermissionsUpdateData The updated permissions
client.on('applicationCommandPermissionsUpdate', (request) => {
    console.log(`applicationCommandPermissionsUpdate: ${request}`);
});

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}`);
});

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}`);
});

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}`);
});

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
addedMembers Collection<Snowflake, ThreadMember> The members before the update
removedMembers Collection<Snowflake, ThreadMember> The members after the update
client.on('threadMembersUpdate', (oldMembers, newMembers) => {
    console.log(`threadMembersUpdate: ${addedMembers} | ${removedMembers}`);
});

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 The channel that had a webhook update
client.on('webhookUpdate', (channel) => {
    console.log(`webhookUpdate: ${channel}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment