Events
Client extends an EventEmitter. Listen with client.on('name', handler). Handlers are fully typed.
Client extends an EventEmitter. Listen with client.on('name', handler). Handlers are fully typed.
client.on('messageCreate', (message) => {
// message is a Message
});Lifecycle
| Event | Arguments |
|---|---|
ready | () once all shards are ready |
connect | (shardID) |
disconnect | (error?) |
resume | () |
shardPreReady | (shardID) REST queue released |
shardReady | (shardID) |
shardResume | (shardID) |
shardDisconnect | (error, shardID) |
hello | (trace, shardID) |
error | (error, shard?) always handle this |
debug | (info, shard?) verbose; dev only |
warn | (info, shard?) |
rawWS | (packet, shardID) every gateway packet |
rawREST | (data) after every REST call |
unknown | (packet, shardID) dispatch Athena does not recognise |
Users, members, voice
userUpdate, presenceUpdate, voiceStateUpdate, voiceChannelJoin, voiceChannelLeave, voiceChannelSwitch, typingStart, guildMemberAdd, guildMemberUpdate, guildMemberRemove, guildMemberChunk.
Messages
messageCreate, messageUpdate, messageDelete, messageDeleteBulk, messageReactionAdd, messageReactionRemove, messageReactionRemoveAll, messageReactionRemoveEmoji, channelPinUpdate, messagePollVoteAdd, messagePollVoteRemove.
For events on objects not in cache, Athena gives a partial (for example a message with only id, channel, guildID). Guard with instanceof Message when you need full data.
Guilds, channels, threads
guildAvailable, guildCreate, unavailableGuildCreate, guildUpdate, guildUnavailable, guildDelete, guildBanAdd, guildBanRemove, guildRoleCreate, guildRoleUpdate, guildRoleDelete, guildEmojisUpdate, guildStickersUpdate, inviteCreate, inviteDelete, channelCreate, channelUpdate, channelDelete, webhooksUpdate, threadCreate, threadUpdate, threadDelete, threadListSync, threadMemberUpdate, threadMembersUpdate, stageInstanceCreate, stageInstanceUpdate, stageInstanceDelete, guildAuditLogEntryCreate.
Integrations, soundboard, automod, scheduled events
integrationCreate, integrationUpdate, integrationDelete, guildIntegrationsUpdate, soundboardSounds, guildSoundboardSoundCreate, guildSoundboardSoundUpdate, guildSoundboardSoundDelete, guildSoundboardSoundsUpdate, voiceChannelEffectSend, applicationCommandPermissionsUpdate, autoModerationRuleCreate, autoModerationRuleUpdate, autoModerationRuleDelete, autoModerationActionExecution, guildScheduledEventCreate, guildScheduledEventUpdate, guildScheduledEventDelete, guildScheduledEventUserAdd, guildScheduledEventUserRemove.
Interactions
interactionCreate fires for every interaction. Narrow it with type guards:
client.on('interactionCreate', (interaction) => {
if (interaction.isCommand()) { /* CommandInteraction */ }
else if (interaction.isComponent()) { /* ComponentInteraction */ }
else if (interaction.isModal()) { /* ModalSubmitInteraction */ }
else if (interaction.isAutocomplete()) { /* AutocompleteInteraction */ }
});Monetization
entitlementCreate, entitlementUpdate, entitlementDelete, subscriptionCreate, subscriptionUpdate, subscriptionDelete.
CommandClient extras
When using the commands framework: commandError and commandExecuted.
The catch-all
event fires for every emit: (eventName, ...args). Handy for one central logger.
Tips
- Always attach an
errorlistener. - Subscribe to
debugonly in development; it is very chatty. - Uncached objects are normal for bots that restart often. Handle the partial case.