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.
List of events in this overview
- applicationCommandPermissionsUpdate
- apiRequest
- apiResponse
- channelCreate
- channelDelete
- channelPinsUpdate
- channelUpdate
- debug
- emojiCreate
- emojiDelete
- emojiUpdate
- error
- guildBanAdd
- guildBanRemove
- guildCreate
- guildDelete
- guildIntegrationsUpdate
- guildMemberAdd
- guildMemberAvailable
- guildMemberRemove
- guildMembersChunk
- guildMemberUpdate
- guildScheduledEventCreate
- guildScheduledEventDelete
- guildScheduledEventUpdate
- guildScheduledEventUserAdd
- guildScheduledEventUserRemove
- guildUnavailable
- guildUpdate
- interaction
- interactionCreate
- invalidated
- invalidRequestWarning
- inviteCreate
- inviteDelete
- messageCreate
- messageDelete
- messageDeleteBulk
- messageReactionAdd
- messageReactionRemove
- messageReactionRemoveAll
- messageReactionRemoveEmoji
- messageUpdate
- presenceUpdate
- rateLimit
- ready
- roleCreate
- roleDelete
- roleUpdate
- shardDisconnect
- shardError
- shardReady
- shardReconnecting
- shardResume
- stageInstanceCreate
- stageInstanceDelete
- stageInstanceUpdate
- stickerCreate
- stickerDelete
- stickerUpdate
- threadCreate
- threadDelete
- threadListSync
- threadMembersUpdate
- threadUpdate
- typingStart
- userUpdate
- voiceStateUpdate
- warn
- webhookUpdate
⚠️ | This includes permission updates for other applications in addition to the logged in client, checkdata.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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
Emitted for general debugging information.
Parameter | Type | Description |
---|---|---|
info | string | The debug info |
client.on('debug', (debug) => {
console.log(`debug: ${info}`);
});
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}`);
});
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}`);
});
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}`);
});
Emitted when the client encounters an error.
Parameter | Type | Description |
---|---|---|
error | error | The error that encountered |
client.on('error', (error) => {
console.log(`error: ${error}`);
});
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}`);
});
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}`);
});
Emitted whenever the client joins a guild.
Parameter | Type | Description |
---|---|---|
guild | Guild | The created guild |
client.on('guildCreate', (guild) => {
console.log(`guildCreate: ${guild}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
Emitted when an interaction is created.
Parameter | Type | Description |
---|---|---|
interaction | Interaction | The interaction which was created |
client.on('interactionCreate', (interaction) => {
console.log(`interactionCreate: ${interaction}`);
});
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`);
});
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}`);
});
ℹ️ | This event only triggers if the client has
MANAGE_GUILD
permissions for the guild, orMANAGE_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}`);
});
ℹ️ | This event only triggers if the client has
MANAGE_GUILD
permissions for the guild, orMANAGE_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}`);
});
Emitted when a message is created.
Parameter | Type | Description |
---|---|---|
message | Message | The created message |
client.on('messageCreate', (message) => {
console.log(`messageCreate: ${message}`);
});
Emitted whenever a message is deleted.
Parameter | Type | Description |
---|---|---|
message | Message | The deleted message |
client.on('messageDelete', (message) => {
console.log(`messageDelete: ${message}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
Emitted when the client becomes ready to start working.
Parameter | Type | Description |
---|---|---|
client | Client | The client |
client.on('ready', (client) => {
console.log(`ready: ${client}`);
});
Emitted whenever a role is created.
Parameter | Type | Description |
---|---|---|
role | Role | The role that was created |
client.on('roleCreate', (role) => {
console.log(`roleCreate: ${role}`);
});
Emitted whenever a role is deleted.
Parameter | Type | Description |
---|---|---|
role | Role | The role that was deleted |
client.on('roleDelete', (role) => {
console.log(`roleDelete: ${role}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
Emitted whenever a stage instance is created.
Parameter | Type | Description |
---|---|---|
stageInstance | StageInstance | The created stage instance |
client.on('stageInstanceCreate', (stageInstance) => {
console.log(`stageInstanceCreate: ${stageInstance}`);
});
Emitted whenever a stage instance is deleted.
Parameter | Type | Description |
---|---|---|
stageInstance | StageInstance | The deleted stage instance |
client.on('stageInstanceDelete', (stageInstance) => {
console.log(`stageInstanceDelete: ${stageInstance}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
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}`);
});
ℹ️ | Triggered by the Discord gateway events
USER_UPDATE
,GUILD_MEMBER_UPDATE
, andPRESENCE_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}`);
});
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}`);
});
Emitted for general warnings.
Parameter | Type | Description |
---|---|---|
info | string | The warning |
client.on('warn', (info) => {
console.log(`warn: ${info}`);
});
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}`);
});