Client
classe · Source
The main hub for user-account Discord workflows.
Extends: BaseClient
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
options? | ClientOptions | Options for the client |
Properties
_cleanups
Functions called when a cache is garbage collected or the Client is destroyed Source
_finalizers
The finalizers used to cleanup items. Source
ws
The WebSocket manager of the client Source
actions
The action manager of the client Source
voice
The voice manager of the client Source
voiceStates
A manager of the voice states of this client (Support DM / Group DM) Source
shard
Shard helpers for the client (only if the process was spawned from a ShardingManager) Source
users
The user manager of this client Source
guilds
A manager of all the guilds the client is currently handling - this will be every guild the user account is a member of Source
channels
All of the Channels that the client is currently handling - this will be every cached channel in every guild the user account is a member of. Note that DM channels will not be initially cached, and thus not be present in the Manager without their explicit fetching or use. Source
sweepers
The sweeping functions and their intervals used to periodically sweep caches Source
presence
The presence of the Client Source
presences
A manager of the presences belonging to this client Source
notes
All of the note that have been cached at any point, mapped by their ids Source
relationships
All of the relationships UserSource
billing
Manages the API methods Source
sessions
All of the sessions of the client Source
settings
All of the settings ObjectSource
token
Authorization token for the logged in user account. If present, this defaults to process.env.DISCORD_TOKEN when instantiating the client This should be kept private at all times. Source
user
User that the client is logged in as Source
readyAt
Time at which the client was last regarded as being in the READY state (each time the client disconnects and successfully reconnects, this will be overwritten) Source
authenticator
The authenticator used for TOTP Source
emojis
A manager of all the custom emojis that the client has access to Source
readyTimestamp
Timestamp of the time the client was last READY at Source
uptime
How long it has been since the client last entered the READY state in milliseconds Source
sessionId
The current session id of the shard Source
options
The options the client was instantiated with Source
rest
The REST manager of the client Source
api
API shortcut Source
Methods
login
Logs the client in, establishing a WebSocket connection to Discord. Parameters
| Name | Type | Description |
|---|---|---|
token? | string | Token of the account to log in with Default: this.token. |
Returns: Promise<string> — Token of the account used
client.login('my token');passLogin
Logs the client in, establishing a WebSocket connection to Discord. Parameters
| Name | Type | Description |
|---|---|---|
email | string | The email associated with the account |
password | string | The password assicated with the account |
Returns: string \| null — Token of the account used
client.passLogin("test@gmail.com", "SuperSecretPa$$word", 1234)isReady
Returns whether the client has logged in, indicative of being able to access properties such as user. Returns: booleanSource
destroy
Logs out, terminates the connection to Discord, and destroys the client. Returns: voidSource
logout
Logs out, terminates the connection to Discord, destroys the client and destroys the token. Returns: Promise<void>Source
fetchInvite
Obtains an invite from Discord. Parameters
| Name | Type | Description |
|---|---|---|
invite | InviteResolvable | Invite code or URL |
options? | ClientFetchInviteOptions | Options for fetching the invite |
Returns: Promise<Invite>
client.fetchInvite('https://discord.gg/djs')
.then(invite => console.log(`Obtained invite with code: ${invite.code}`))
.catch(console.error);fetchGuildTemplate
Obtains a template from Discord. Parameters
| Name | Type | Description |
|---|---|---|
template | GuildTemplateResolvable | Template code or URL |
Returns: Promise<GuildTemplate>
client.fetchGuildTemplate('https://discord.new/FKvmczH2HyUf')
.then(template => console.log(`Obtained template with code: ${template.code}`))
.catch(console.error);fetchWebhook
Obtains a webhook from Discord. Parameters
| Name | Type | Description |
|---|---|---|
id | Snowflake | The webhook's id |
token? | string | Token for the webhook |
Returns: Promise<Webhook>
client.fetchWebhook('id', 'token')
.then(webhook => console.log(`Obtained webhook with name: ${webhook.name}`))
.catch(console.error);fetchVoiceRegions
Obtains the available voice regions from Discord. Returns: Promise<Collection<string, VoiceRegion>>
client.fetchVoiceRegions()
.then(regions => console.log(`Available regions are: ${regions.map(region => region.name).join(', ')}`))
.catch(console.error);fetchSticker
Obtains a sticker from Discord. Parameters
| Name | Type | Description |
|---|---|---|
id | Snowflake | The sticker's id |
Returns: Promise<Sticker>
client.fetchSticker('id')
.then(sticker => console.log(`Obtained sticker with name: ${sticker.name}`))
.catch(console.error);fetchPremiumStickerPacks
Obtains the list of sticker packs available to Nitro subscribers from Discord. Returns: Promise<Collection<Snowflake, StickerPack>>
client.fetchPremiumStickerPacks()
.then(packs => console.log(`Available sticker packs are: ${packs.map(pack => pack.name).join(', ')}`))
.catch(console.error);_finalize
A last ditch cleanup function for garbage collection. Parameters
| Name | Type | Description |
|---|---|---|
options.cleanup | function | The function called to GC |
options.message? | string | The message to send after a successful GC |
options.name? | string | The name of the item being GCed |
| Source |
sweepMessages
Sweeps all text-based channels' messages and removes the ones older than the max message lifetime. If the message has been edited, the time of the edit is used rather than the time of the original message. Parameters
| Name | Type | Description |
|---|---|---|
lifetime? | number | Messages that are older than this (in seconds) will be removed from the caches. The default is based on ClientOptions#messageCacheLifetime Default: this.options.messageCacheLifetime. |
Returns: number — Amount of messages that were removed from the caches, or -1 if the message cache lifetime is unlimited
// Remove all messages older than 1800 seconds from the messages cache
const amount = client.sweepMessages(1800);
console.log(`Successfully removed ${amount} messages from the cache.`);fetchGuildPreview
Obtains a guild preview from Discord, available for joined guilds and Discoverable guilds. Parameters
| Name | Type | Description |
|---|---|---|
guild | GuildResolvable | The guild to fetch the preview for |
Returns: Promise<GuildPreview>Source
fetchGuildWidget
Obtains the widget data of a guild from Discord, available for guilds with the widget enabled. Parameters
| Name | Type | Description |
|---|---|---|
guild | GuildResolvable | The guild to fetch the widget data for |
Returns: Promise<Widget>Source
refreshAttachmentURL
Refresh the Discord CDN links with hashes so they can be usable. Parameters
| Name | Type | Description |
|---|---|---|
urls | string | Discord CDN URLs |
Returns: Promise<Array<{original: string, refreshed: string}>>Source
sleep
The sleep function in JavaScript returns a promise that resolves after a specified timeout. Parameters
| Name | Type | Description |
|---|---|---|
timeout | number | The timeout parameter is the amount of time, in milliseconds, that the sleep function will wait before resolving the promise and continuing execution. |
Returns: void — The sleep function is returning a Promise. Source
acceptInvite
Join this Guild / GroupDMChannel using this invite Parameters
| Name | Type | Description |
|---|---|---|
invite | InviteResolvable | Invite code or URL |
options? | AcceptInviteOptions | Options |
Returns: Promise<(Guild\|DMChannel\|GroupDMChannel)>
await client.acceptInvite('https://discord.gg/genshinimpact', { bypassOnboarding: true, bypassVerify: true })redeemNitro
Redeem nitro from code or url. Parameters
| Name | Type | Description |
|---|---|---|
nitro | string | Nitro url or code |
channel? | TextChannelResolvable | Channel that the code was sent in |
paymentSourceId? | Snowflake | Payment source id |
Returns: Promise<any>Source
authorizeURL
Authorize an application. Parameters
| Name | Type | Description |
|---|---|---|
urlOAuth2 | string | Discord Auth URL |
options? | OAuth2AuthorizeOptions | Oauth2 options |
Returns: Promise<{location: string}>
client.authorizeURL(`https://discord.com/api/oauth2/authorize?client_id=botID&permissions=8&scope=applications.commands%20bot`, {
guild_id: "guildID",
})installUserApps
Install User Apps Parameters
| Name | Type | Description |
|---|---|---|
applicationId | Snowflake | Discord Application id |
Returns: Promise<void>Source
deauthorize
Deauthorizes an application or token. Parameters
| Name | Type | Description |
|---|---|---|
id | Snowflake | The ID of the Discord Application or Token. |
type? | 'application' | 'token' | The type of the ID provided. Defaults to 'application'. Default: 'application'. |
Returns: Promise<void> — A promise that resolves when the deauthorization is complete. Source
authorizedApplications
Retrieves the list of authorized applications (OAuth2 tokens). Returns: Promise<Collection<Snowflake, AuthorizedApplicationData>>Source
_eval
Calls https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/eval on a script with the client as this. Parameters
| Name | Type | Description |
|---|---|---|
script | string | Script to eval |
Returns: *Source
_validateOptions
Validates the client options. Parameters
| Name | Type | Description |
|---|---|---|
options? | ClientOptions | Options to validate Default: this.options. |
| Source |
incrementMaxListeners
Increments max listeners by one, if they are not zero. Source
decrementMaxListeners
Decrements max listeners by one, if they are not zero. Source
Events
applicationCommandPermissionsUpdate
Emitted whenever permissions for an application command in a guild were updated. 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 Parameters
| Name | Type | Description |
|---|---|---|
data | ApplicationCommandPermissionsUpdateData | The updated permissions |
| Source |
autoModerationActionExecution
Emitted whenever an auto moderation rule is triggered. This event requires the Permissions.FLAGS.MANAGE_GUILD permission. Parameters
| Name | Type | Description |
|---|---|---|
autoModerationActionExecution | AutoModerationActionExecution | The data of the execution |
| Source |
autoModerationRuleCreate
Emitted whenever an auto moderation rule is created. This event requires the Permissions.FLAGS.MANAGE_GUILD permission. Parameters
| Name | Type | Description |
|---|---|---|
autoModerationRule | AutoModerationRule | The created auto moderation rule |
| Source |
autoModerationRuleDelete
Emitted whenever an auto moderation rule is deleted. This event requires the Permissions.FLAGS.MANAGE_GUILD permission. Parameters
| Name | Type | Description |
|---|---|---|
autoModerationRule | AutoModerationRule | The deleted auto moderation rule |
| Source |
autoModerationRuleUpdate
Emitted whenever an auto moderation rule gets updated. This event requires the Permissions.FLAGS.MANAGE_GUILD permission. Parameters
| Name | Type | Description |
|---|---|---|
oldAutoModerationRule | AutoModerationRule | The auto moderation rule before the update |
newAutoModerationRule | AutoModerationRule | The auto moderation rule after the update |
| Source |
channelCreate
Emitted whenever a guild channel is created. Parameters
| Name | Type | Description |
|---|---|---|
channel | GuildChannel | The channel that was created |
| Source |
channelDelete
Emitted whenever a channel is deleted. Parameters
| Name | Type | Description |
|---|---|---|
channel | DMChannel | GuildChannel | The channel that was deleted |
| Source |
guildAuditLogEntryCreate
Emitted whenever a guild audit log entry is created. Parameters
| Name | Type | Description |
|---|---|---|
auditLogEntry | GuildAuditLogsEntry | The entry that was created |
guild | Guild | The guild where the entry was created |
| Source |
guildBanAdd
Emitted whenever a member is banned from a guild. Parameters
| Name | Type | Description |
|---|---|---|
ban | GuildBan | The ban that occurred |
| Source |
guildBanRemove
Emitted whenever a member is unbanned from a guild. Parameters
| Name | Type | Description |
|---|---|---|
ban | GuildBan | The ban that was removed |
| Source |
guildUnavailable
Emitted whenever a guild becomes unavailable, likely due to a server outage. Parameters
| Name | Type | Description |
|---|---|---|
guild | Guild | The guild that has become unavailable |
| Source |
guildDelete
Emitted whenever a guild kicks the client or the guild is deleted/left. Parameters
| Name | Type | Description |
|---|---|---|
guild | Guild | The guild that was deleted |
| Source |
emojiCreate
Emitted whenever a custom emoji is created in a guild. Parameters
| Name | Type | Description |
|---|---|---|
emoji | GuildEmoji | The emoji that was created |
| Source |
emojiDelete
Emitted whenever a custom emoji is deleted in a guild. Parameters
| Name | Type | Description |
|---|---|---|
emoji | GuildEmoji | The emoji that was deleted |
| Source |
emojiUpdate
Emitted whenever a custom emoji is updated in a guild. Parameters
| Name | Type | Description |
|---|---|---|
oldEmoji | GuildEmoji | The old emoji |
newEmoji | GuildEmoji | The new emoji |
| Source |
guildIntegrationsUpdate
Emitted whenever a guild integration is updated Parameters
| Name | Type | Description |
|---|---|---|
guild | Guild | The guild whose integrations were updated |
| Source |
guildMemberRemove
Emitted whenever a member leaves a guild, or is kicked. Parameters
| Name | Type | Description |
|---|---|---|
member | GuildMember | The member that has left/been kicked from the guild |
| Source |
guildMemberUpdate
Emitted whenever a guild member changes - i.e. new role, removed role, nickname. Parameters
| Name | Type | Description |
|---|---|---|
oldMember | GuildMember | The member before the update |
newMember | GuildMember | The member after the update |
| Source |
guildMemberAvailable
Emitted whenever a member becomes available. Parameters
| Name | Type | Description |
|---|---|---|
member | GuildMember | The member that became available |
| Source |
roleCreate
Emitted whenever a role is created. Parameters
| Name | Type | Description |
|---|---|---|
role | Role | The role that was created |
| Source |
roleDelete
Emitted whenever a guild role is deleted. Parameters
| Name | Type | Description |
|---|---|---|
role | Role | The role that was deleted |
| Source |
roleUpdate
Emitted whenever a guild role is updated. Parameters
| Name | Type | Description |
|---|---|---|
oldRole | Role | The role before the update |
newRole | Role | The role after the update |
| Source |
guildScheduledEventCreate
Emitted whenever a guild scheduled event is created. Parameters
| Name | Type | Description |
|---|---|---|
guildScheduledEvent | GuildScheduledEvent | The created guild scheduled event |
| Source |
guildScheduledEventDelete
Emitted whenever a guild scheduled event is deleted. Parameters
| Name | Type | Description |
|---|---|---|
guildScheduledEvent | GuildScheduledEvent | The deleted guild scheduled event |
| Source |
guildScheduledEventUpdate
Emitted whenever a guild scheduled event gets updated. Parameters
| Name | Type | Description |
|---|---|---|
oldGuildScheduledEvent | GuildScheduledEvent | The guild scheduled event object before the update |
newGuildScheduledEvent | GuildScheduledEvent | The guild scheduled event object after the update |
| Source |
guildScheduledEventUserAdd
Emitted whenever a user subscribes to a guild scheduled event Parameters
| Name | Type | Description |
|---|---|---|
guildScheduledEvent | GuildScheduledEvent | The guild scheduled event |
user | User | The user who subscribed |
| Source |
guildScheduledEventUserRemove
Emitted whenever a user unsubscribes from a guild scheduled event Parameters
| Name | Type | Description |
|---|---|---|
guildScheduledEvent | GuildScheduledEvent | The guild scheduled event |
user | User | The user who unsubscribed |
| Source |
stickerCreate
Emitted whenever a custom sticker is created in a guild. Parameters
| Name | Type | Description |
|---|---|---|
sticker | Sticker | The sticker that was created |
| Source |
stickerDelete
Emitted whenever a custom sticker is deleted in a guild. Parameters
| Name | Type | Description |
|---|---|---|
sticker | Sticker | The sticker that was deleted |
| Source |
stickerUpdate
Emitted whenever a custom sticker is updated in a guild. Parameters
| Name | Type | Description |
|---|---|---|
oldSticker | Sticker | The old sticker |
newSticker | Sticker | The new sticker |
| Source |
guildUpdate
Emitted whenever a guild is updated - e.g. name change. Parameters
| Name | Type | Description |
|---|---|---|
oldGuild | Guild | The guild before the update |
newGuild | Guild | The guild after the update |
| Source |
inviteCreate
Emitted when an invite is created. This event only triggers if the client has MANAGE_GUILD permissions for the guild, or MANAGE_CHANNELS permissions for the channel. Parameters
| Name | Type | Description |
|---|---|---|
invite | Invite | The invite that was created |
| Source |
inviteDelete
Emitted when an invite is deleted. This event only triggers if the client has MANAGE_GUILD permissions for the guild, or MANAGE_CHANNELS permissions for the channel. Parameters
| Name | Type | Description |
|---|---|---|
invite | Invite | The invite that was deleted |
| Source |
messageCreate
Emitted whenever a message is created. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The created message |
| Source |
message
Emitted whenever a message is created. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The created message |
| Source |
messageDelete
Emitted whenever a message is deleted. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The deleted message |
| Source |
messageDeleteBulk
Emitted whenever messages are deleted in bulk. Parameters
| Name | Type | Description |
|---|---|---|
messages | Collection<Snowflake, Message> | The deleted messages, mapped by their id |
| Source |
messagePollVoteAdd
Emitted whenever a user votes in a poll. Parameters
| Name | Type | Description |
|---|---|---|
pollAnswer | PollAnswer | The answer that was voted on |
userId | Snowflake | The id of the user that voted |
| Source |
messagePollVoteRemove
Emitted whenever a user removes their vote in a poll. Parameters
| Name | Type | Description |
|---|---|---|
pollAnswer | PollAnswer | The answer where the vote was removed |
userId | Snowflake | The id of the user that removed their vote |
| Source |
messageReactionAdd
Emitted whenever a reaction is added to a cached message. Parameters
| Name | Type | Description |
|---|---|---|
messageReaction | MessageReaction | The reaction object |
user | User | The user that applied the guild or reaction emoji |
details | MessageReactionEventDetails | Details of adding the reaction |
| Source |
messageReactionRemove
Emitted whenever a reaction is removed from a cached message. Parameters
| Name | Type | Description |
|---|---|---|
messageReaction | MessageReaction | The reaction object |
user | User | The user whose emoji or reaction emoji was removed |
details | MessageReactionEventDetails | Details of removing the reaction |
| Source |
messageReactionRemoveAll
Emitted whenever all reactions are removed from a cached message. Parameters
| Name | Type | Description |
|---|---|---|
message | Message | The message the reactions were removed from |
reactions | Collection<(string|Snowflake), MessageReaction> | The cached message reactions that were removed. |
| Source |
messageReactionRemoveEmoji
Emitted when a bot removes an emoji reaction from a cached message. Parameters
| Name | Type | Description |
|---|---|---|
reaction | MessageReaction | The reaction that was removed |
| Source |
presenceUpdate
Emitted whenever a guild member's presence (e.g. status, activity) is changed. Parameters
| Name | Type | Description |
|---|---|---|
oldPresence | Presence | The presence before the update, if one at all |
newPresence | Presence | The presence after the update |
| Source |
stageInstanceCreate
Emitted whenever a stage instance is created. Parameters
| Name | Type | Description |
|---|---|---|
stageInstance | StageInstance | The created stage instance |
| Source |
stageInstanceDelete
Emitted whenever a stage instance is deleted. Parameters
| Name | Type | Description |
|---|---|---|
stageInstance | StageInstance | The deleted stage instance |
| Source |
stageInstanceUpdate
Emitted whenever a stage instance gets updated - e.g. change in topic or privacy level Parameters
| Name | Type | Description |
|---|---|---|
oldStageInstance | StageInstance | The stage instance before the update |
newStageInstance | StageInstance | The stage instance after the update |
| Source |
threadCreate
Emitted whenever a thread is created or when the client user is added to a thread. Parameters
| Name | Type | Description |
|---|---|---|
thread | ThreadChannel | The thread that was created |
newlyCreated | boolean | Whether the thread was newly created |
| Source |
threadDelete
Emitted whenever a thread is deleted. Parameters
| Name | Type | Description |
|---|---|---|
thread | ThreadChannel | The thread that was deleted |
| Source |
threadListSync
Emitted whenever the client user gains access to a text or news channel that contains threads Parameters
| Name | Type | Description |
|---|---|---|
threads | Collection<Snowflake, ThreadChannel> | The threads that were synced |
| Source |
threadMembersUpdate
Emitted whenever members are added or removed from a thread. Requires GUILD_MEMBERS privileged intent Parameters
| Name | Type | Description |
|---|---|---|
oldMembers | Collection<Snowflake, ThreadMember> | The members before the update |
newMembers | Collection<Snowflake, ThreadMember> | The members after the update |
| Source |
threadMemberUpdate
Emitted whenever the client user's thread member is updated. Parameters
| Name | Type | Description |
|---|---|---|
oldMember | ThreadMember | The member before the update |
newMember | ThreadMember | The member after the update |
| Source |
typingStart
Emitted whenever a user starts typing in a channel. Parameters
| Name | Type | Description |
|---|---|---|
typing | Typing | The typing state |
| Source |
userUpdate
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. Parameters
| Name | Type | Description |
|---|---|---|
oldUser | User | The user before the update |
newUser | User | The user after the update |
| Source |
voiceStateUpdate
Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes. Parameters
| Name | Type | Description |
|---|---|---|
oldState | VoiceState | The voice state before the update |
newState | VoiceState | The voice state after the update |
| Source |
webhookUpdate
Emitted whenever a channel has its webhooks changed. Parameters
| Name | Type | Description |
|---|---|---|
channel | TextChannel | NewsChannel | VoiceChannel | StageChannel | ForumChannel | MediaChannel | The channel that had a webhook update |
| Source |
warn
Emitted for general warnings. Parameters
| Name | Type | Description |
|---|---|---|
info | string | The warning |
| Source |
guildMemberSpeaking
Emitted once a guild member changes speaking state. Parameters
| Name | Type | Description |
|---|---|---|
member | GuildMember | The member that started/stopped speaking |
speaking | Readonly<Speaking> | The speaking state of the member |
| Source |
applicationCommandCreate
Emitted when a guild application command is created. Parameters
| Name | Type | Description |
|---|---|---|
command | ApplicationCommand | The command which was created |
| Source |
applicationCommandDelete
Emitted when a guild application command is deleted. Parameters
| Name | Type | Description |
|---|---|---|
command | ApplicationCommand | The command which was deleted |
| Source |
applicationCommandUpdate
Emitted when a guild application command is updated. Parameters
| Name | Type | Description |
|---|---|---|
oldCommand | ApplicationCommand | The command before the update |
newCommand | ApplicationCommand | The command after the update |
| Source |
callCreate
Emitted whenever received a call Parameters
| Name | Type | Description |
|---|---|---|
call | CallState | Call |
| Source |
callDelete
Emitted whenever delete a call Parameters
| Name | Type | Description |
|---|---|---|
call | Call | Call |
| Source |
callUpdate
Emitted whenever update a call Parameters
| Name | Type | Description |
|---|---|---|
call | Call | Call |
| Source |
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. Parameters
| Name | Type | Description |
|---|---|---|
channel | TextBasedChannels | The channel that the pins update occurred in |
time | Date | The time of the pins update |
| Source |
channelRecipientAdd
Emitted whenever a recipient is added from a group DM. Parameters
| Name | Type | Description |
|---|---|---|
channel | GroupDMChannel | Group DM channel |
user | User | User |
| Source |
channelRecipientRemove
Emitted whenever a recipient is removed from a group DM. Parameters
| Name | Type | Description |
|---|---|---|
channel | GroupDMChannel | Group DM channel |
user | User | User |
| Source |
channelUpdate
Emitted whenever a channel is updated - e.g. name change, topic change, channel type change. Parameters
| Name | Type | Description |
|---|---|---|
oldChannel | DMChannel | GuildChannel | The channel before the update |
newChannel | DMChannel | GuildChannel | The channel after the update |
| Source |
guildAvailable
Emitted whenever a guild becomes available. Parameters
| Name | Type | Description |
|---|---|---|
guild | Guild | The guild that became available |
| Source |
guildCreate
Emitted whenever the client joins a guild. Parameters
| Name | Type | Description |
|---|---|---|
guild | Guild | The created guild |
| Source |
guildMemberAdd
Emitted whenever a user joins a guild. Parameters
| Name | Type | Description |
|---|---|---|
member | GuildMember | The member that has joined a guild |
| Source |
guildMembersChunk
Emitted whenever a chunk of guild members is received (all members come from the same guild). Parameters
| Name | 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 |
| Source |
interactionModalCreate
Emitted whenever client user receive interaction.showModal() Parameters
| Name | Type | Description |
|---|---|---|
modal | Modal | The modal (extended) |
| Source |
messageUpdate
Emitted whenever a message is updated - e.g. embed or content change. Parameters
| Name | Type | Description |
|---|---|---|
oldMessage | Message | The message before the update |
newMessage | Message | The message after the update |
| Source |
relationshipAdd
Emitted when a relationship is created, relevant to the current user. Parameters
| Name | Type | Description |
|---|---|---|
user | Snowflake | Target userId |
shouldNotify | boolean | Whether the client should notify the user of this relationship's creation |
| Source |
relationshipRemove
Emitted when a relationship is removed, relevant to the current user. Parameters
| Name | Type | Description |
|---|---|---|
user | Snowflake | The userID that was updated |
type | RelationshipType | The type of the old relationship |
nickname | string | null | The nickname of the user in this relationship (1-32 characters) |
| Source |
relationshipUpdate
Emitted when a relationship is updated, relevant to the current user (e.g. friend nickname changed). This is not sent when the type of a relationship changes; see Client#relationshipAdd and Client#relationshipRemove for that. Parameters
| Name | Type | Description |
|---|---|---|
user | Snowflake | The userID that was updated |
oldData | RelationshipUpdateObject | Old data |
newData | RelationshipUpdateObject | New data |
| Source |
shardResume
Emitted when a shard resumes successfully. Parameters
| Name | Type | Description |
|---|---|---|
id | number | The shard id that resumed |
replayedEvents | number | The amount of replayed events |
| Source |
threadUpdate
Emitted whenever a thread is updated - e.g. name change, archive state change, locked state change. Parameters
| Name | Type | Description |
|---|---|---|
oldThread | ThreadChannel | The thread before the update |
newThread | ThreadChannel | The thread after the update |
| Source |
voiceChannelEffectSend
Emmited when someone sends an effect, such as an emoji reaction, in a voice channel the client is connected to. Parameters
| Name | Type | Description |
|---|---|---|
voiceChannelEffect | VoiceChannelEffect | The sent voice channel effect |
| Source |
shardReady
Emitted when a shard turns ready. Parameters
| Name | Type | Description |
|---|---|---|
id | number | The shard id that turned ready |
unavailableGuilds | Set<Snowflake> | Set of unavailable guild ids, if any |
| Source |
shardDisconnect
Emitted when a shard's WebSocket disconnects and will no longer reconnect. Parameters
| Name | Type | Description |
|---|---|---|
event | CloseEvent | The WebSocket close event |
id | number | The shard id that disconnected |
| Source |
shardReconnecting
Emitted when a shard is attempting to reconnect or re-identify. Parameters
| Name | Type | Description |
|---|---|---|
id | number | The shard id that is attempting to reconnect |
| Source |
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. Source
unhandledPacket
Emitted whenever a packet isn't handled. Parameters
| Name | Type | Description |
|---|---|---|
packet | Object | The packet (t: EVENT_NAME, d: any) |
shard | Number | The shard that received the packet (Shard 0) |
| Source |
ready
Emitted when the client becomes ready to start working. Parameters
| Name | Type | Description |
|---|---|---|
client | Client | The client |
| Source |
shardError
Emitted whenever a shard's WebSocket encounters a connection error. Parameters
| Name | Type | Description |
|---|---|---|
error | Error | The encountered error |
shardId | number | The shard that encountered this error |
| Source |
error
Emitted when the client encounters an error. Errors thrown within this event do not have a catch handler, it is recommended to not use async functions as error event handlers. See the Node.js docs for details. Parameters
| Name | Type | Description |
|---|---|---|
error | Error | The error encountered |
| Source |
debug
Emitted for general debugging information. Parameters
| Name | Type | Description |
|---|---|---|
info | string | The debug information |
| Source |
rateLimit
Emitted when the client hits a rate limit while making a request Parameters
| Name | Type | Description |
|---|---|---|
rateLimitData | RateLimitData | Object containing the rate limit info |
| Source |
apiRequest
Emitted before every API request. This event can emit several times for the same request, e.g. when hitting a rate limit. This is an informational event that is emitted quite frequently, it is highly recommended to check request.path to filter the data. Parameters
| Name | Type | Description |
|---|---|---|
request | APIRequest | The request that is about to be sent |
| Source |
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. This is an informational event that is emitted quite frequently, it is highly recommended to check request.path to filter the data. Parameters
| Name | Type | Description |
|---|---|---|
request | APIRequest | The request that triggered this response |
response | Response | The response received from the Discord API |
| Source |
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 Parameters
| Name | Type | Description |
|---|---|---|
invalidRequestWarningData | InvalidRequestWarningData | Object containing the invalid request info |
| Source |