A quick guide for all available events can be obtained from here: https://discord.js.org/#/docs/main/stable/class/Client
- Basic knowledge on JavaScript
- Basic knowledge on Discord.JS (v14)
- Basic knowledge on Node.JS
channelCreate
Description:
Emitted whenever a guild channel is created.
PARAMETER | Type | Description |
---|---|---|
channel |
GuildChannel |
The channel that was created |
client.on("channelCreate", (channel) => {
console.log(`${channel} has been created`)
})
channelDelete
Description:
Emitted whenever a guild channel is deleted.
PARAMETER | Type | Description |
---|---|---|
channel |
GuildChannel |
The channel that was deleted |
client.on("channelDelete", (channel) => {
console.log(`${channel} has been deleted`)
})
channelPinsUpdate
Description:
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 |
GuildChannel |
The time of the pins update |
time |
Date |
The channel that was deleted |
client.on("channelPinsUpdate", (channel, time) => {
console.log(`${channel}'s pin has been updated at ${time}`)
})
channelUpdate
Description:
Emitted whenever a channel is updated - e.g. name change, topic change, channel type change.
PARAMETER | Type | Description |
---|---|---|
oldChannel |
DMChannel/GuildChannel |
The channel before the update |
newChannel |
DMChannel/GuildChannel |
The channel after the update |
client.on("channelUpdate", (oldChannel, newChannel) => {
console.log(`A channel's data has been updated`)
console.log(`${newChannel}'s name has been updated from, ${oldChannel.name} to ${newChannel.name}`)
})
debug
Description:
Emitted for general debugging information.
PARAMETER | Type | Description |
---|---|---|
info |
String |
The debug information |
client.on("debug", (info) => {
console.log(`Debug logged as ${info}`)
})
emojiCreate
Description:
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(`${emoji} has been created in ${emoji.guild.name}`)
})
emojiDelete
Description:
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(`${emoji} has been deleted in ${emoji.guild.name}`)
})
emojiUpdate
Description:
Emitted whenever a custom guild emoji is updated.
PARAMETER | Type | Description |
---|---|---|
oldEmoji |
GuildEmoji |
The old emoji |
newEmoji |
GuildEmoji |
The new emoji |
client.on("emojiUpdate", (oldEmoji, newEmoji) => {
console.log(`An emoji has been updated`)
console.log(`${oldEmoji.name} has been updated to ${newEmoji.name}`)
})
error
Description:
Emitted whenever the client's WebSocket encounters a connection error.
PARAMETER | Type | Description |
---|---|---|
error |
Error |
The encountered error |
client.on("error", (error) => {
console.log(`Client encountered a connection error: ${error}`)
})
guildBanAdd
Description:
Emitted whenever a member is banned from a guild.
PARAMETER | Type | Description |
---|---|---|
ban |
GuildBan |
The ban that occurred |
client.on("guildBanAdd", (ban) => {
console.log(`${ban.user.tag} has been banned from ${ban.guild.name}`)
})
guildBanRemove
Description:
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(`${ban.user.tag} has been unbanned from ${ban.guild.name}`)
})
guildCreate
Description:
Emitted whenever the client joins a guild.
PARAMETER | Type | Description |
---|---|---|
guild |
Guild |
The created guild |
client.on("guildCreate", (guild) => {
console.log(`The bot has joined ${guild.name}`)
})
guildDelete
Description:
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(`The bot has left ${guild.name}`)
})
guildIntegrationsUpdate
Description:
Emitted whenever a guild integration is updated.
PARAMETER | Type | Description |
---|---|---|
guild |
Guild |
The guild whose integrations were updated |
client.on("guildIntegrationsUpdate", (guild) => {
console.log(`An integration has been updated in ${guild.name}`)
})
guildMemberAdd
Description:
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(`${member.tag} has joined the server`)
})
guildMemberAvailable
Description:
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(`${member.tag} is now available in ${member.guild.name}`)
})
guildMemberRemove
Description:
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(`${member.tag} has left the server`)
})
guildMembersChunk
Description:
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(`${members.map(member => member.user.tag).join(", ")} (${chunk.count}) has joined from the same server, ${guild.name}`)
})
guildMemberUpdate
Description:
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, newMember) => {
console.log(`A member's data has been updated`)
console.log(`${newMember}'s nickname has been changed from ${oldMember.nickname} to ${newMember.nickname}`)
})
guildScheduledEventCreate
Description:
Emitted whenever a guild scheduled event is created.
PARAMETER | Type | Description |
---|---|---|
guildScheduledEvent |
GuildScheduledEvent |
The created guild scheduled event |
client.on("guildScheduledEventCreate", (guildScheduledEvent) => {
console.log(`An event has been scheduled in ${guildScheduledEvent.channel} by ${guildScheduledEvent.creator} as ${guildScheduledEvent.name}`)
})
guildScheduledEventDelete
Description:
Emitted whenever a guild scheduled event is deleted.
PARAMETER | Type | Description |
---|---|---|
guildScheduledEvent |
GuildScheduledEvent |
The deleted guild scheduled event |
client.on("guildScheduledEventDelete", (guildScheduledEvent) => {
console.log(`An event has been deleted in ${guildScheduledEvent.channel} by ${guildScheduledEvent.creator} as ${guildScheduledEvent.name}`)
})
guildScheduledEventUpdate
Description:
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 before the update |
client.on("guildScheduledEventUpdate", (oldGuildScheduledEvent, newGuildScheduledEvent) => {
console.log(`An event's name has been updated from ${oldGuildScheduledEvent.name} to ${newGuildScheduledEvent.name}`)
})
guildScheduledEventUserAdd
Description:
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", (guildScheduledEvent, user) => {
console.log(`${user} has subscribed to ${guildScheduledEvent.name}`)
})
guildScheduledEventUserRemove
Description:
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("guildScheduledEventUserAdd", (guildScheduledEvent, user) => {
console.log(`${user} has unsubscribed to ${guildScheduledEvent.name}`)
})
guildUnavailable
Description:
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(`${guild.name} has become unavailable, likely due to a server outage`)
})
guildUpdate
Description:
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(`A guild has been updated`)
console.log(`${oldGuild.name} has been changed to ${newGuild.name}`)
})
interactionCreate
Description:
Emitted when an interaction is created.
PARAMETER | Type | Description |
---|---|---|
interaction |
Interaction |
The interaction which was created |
client.on("interactionCreate", (interaction) => {
console.log(`An interaction has been created in ${interaction.guild.name}`)
})
inviteCreate
Description:
Emitted when an invite is created.
Requirements:
This event only triggers if the client has MANAGE_GUILD
permissions for the guild, or MANAGE_CHANNELS
permissions for the channel.
PARAMETER | Type | Description |
---|---|---|
invite |
Invite |
The invite that was created |
client.on("inviteCreate", (invite) => {
console.log(`An invite has been created by ${invite.inviter.tag}. The code is ${invite.code}`)
})
inviteDelete
Description:
Emitted when an invite is deleted.
Requirements:
This event only triggers if the client has MANAGE_GUILD
permissions for the guild, or MANAGE_CHANNELS
permissions for the channel.
PARAMETER | Type | Description |
---|---|---|
invite |
Invite |
The invite that was deleted |
client.on("inviteDelete", (invite) => {
console.log(`An invite has been deleted by ${invite.inviter.tag}. The code is ${invite.code}`)
})
messageCreate
Description:
Emitted whenever a message is created.
PARAMETER | Type | Description |
---|---|---|
message |
Message |
The created message |
client.on("messageCreate", (message) => {
console.log(`A message has been sent in ${message.channel} as ${message.content}`)
})
messageDelete
Description:
Emitted whenever a message is deleted.
PARAMETER | Type | Description |
---|---|---|
message |
Message |
The deleted message |
client.on("messageDelete", (message) => {
console.log(`A message has been deleted in ${message.channel} as ${message.content}`)
})
messageDeleteBulk
Description:
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(`A lot of messages have been deleted ${messages.map(message => message.content).join(", ")}`)
})
messageReactionAdd
Description:
Emitted whenever a reaction is added to a message.
PARAMETER | Type | Description |
---|---|---|
messageReaction |
MessageReaction |
The reaction object |
user |
User |
The user that applied the emoji or reaction emoji |
client.on("messageReactionAdd", (messageReaction, user) => {
console.log(`A reaction has been added to a message`)
console.log(`${messageReaction.emoji} has been added to a message by ${user.tag}`)
})
messageReactionRemove
Description:
Emitted whenever a reaction is removed from a message.
PARAMETER | Type | Description |
---|---|---|
messageReaction |
MessageReaction |
The reaction object |
user |
User |
The user that removed the emoji or reaction emoji |
client.on("messageReactionRemove", (messageReaction, user) => {
console.log(`A reaction has been removed from a message`)
console.log(`${messageReaction.emoji} has been removed from a message by ${user.tag}`)
})
messageReactionRemoveAll
Description:
Emitted whenever all reactions are removed from a 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(`${reactions.map(reaction => reaction.emoji).join(", ")} has been removed from ${message.id}`)
})
messageUpdate
Description:
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(`A message has been updated`)
console.log(`${oldMessage.content} has been edited to ${newMessage.content}`)
})
presenceUpdate
Description:
Emitted whenever a guild member's presence changes, or they change one of their details.
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(`${newPresence.member}'s presnece has been updated from ${oldPresence.clientStatus} to ${newPresence.clientStatus}`)
})
ready
Description:
Emitted when the client becomes ready to start working.
client.on("ready", () => {
console.log(`${client.user.tag} is now ready!`)
})
roleCreate
Description:
Emitted whenever a role is created.
PARAMETER | Type | Description |
---|---|---|
role |
Role |
The role that was created |
client.on("roleCreate", (role) => {
console.log(`${role} has been created`)
})
roleDelete
Description:
Emitted whenever a role is deleted.
PARAMETER | Type | Description |
---|---|---|
role |
Role |
The role that was deleted |
client.on("roleCreate", (role) => {
console.log(`${role} has been deleted`)
})
roleUpdate
Description:
Emitted whenever a guild 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(`A role has been updated`)
console.log(`${oldRole.name} has been updated to ${newRole.name}`)
})
typingStart
Description:
Emitted whenever a user starts typing in a channel.
PARAMETER | Type | Description |
---|---|---|
channel |
GuildChannel |
The channel the user started typing in |
user |
User |
The user that started typing |
client.on("typingStart", (channel, user) => {
console.log(`${user.tag} has started typing in ${channel}`)
})
userUpdate
Description:
Emitted whenever a user's details (e.g. username) are changed. Triggered by the Discord gateway events USER_UPDATE
, GUILD_MEMBER_UPDATE
, and PRESENCE_UPDATE
.
PARAMETER | Type | Description |
---|---|---|
oldUser |
User |
The user before the update |
newUser |
User |
The user after the update |
client.on("userUpdate", (oldUser, newUser) => {
console.log(`${oldUser.username} has been changed to ${newUser.username}`)
})
voiceStateUpdate
Description:
Emitted whenever a user 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", (oldState, newState) => {
console.log(`${newState.member}'s voice state has been updated`)
})
warn
Description:
Emitted for general warnings.
PARAMETER | Type | Description |
---|---|---|
info |
String |
The warning |
client.on("warn", (info) => {
console.log(`warn: ${info}`)
})
webhookUpdate
Description:
Emitted whenever a channel has its webhooks changed.
PARAMETER | Type | Description |
---|---|---|
channel |
TextChannel/NewsChannel/VoiceChannel |
The channel that had a webhook update |
client.on("webhookUpdate", (channel) => {
console.log(`A webhook name has been updated in ${channel}`)
})