The main hub for interacting with the Discord API, and the starting point for any bot.
Extends
BaseClientName | Constraints | Optional | Default | Description |
---|---|---|---|---|
Ready | boolean | Yes | boolean | None |
Name | Type | Optional | Description |
---|---|---|---|
options | ClientOptions | No | None |
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 forName | Type | Optional | Description |
---|---|---|---|
data | ApplicationCommandPermissionsUpdateData | No | The updated permissions |
Emitted whenever an auto moderation rule is triggered. This event requires the permission.
Name | Type | Optional | Description |
---|---|---|---|
autoModerationActionExecution | AutoModerationActionExecution | No | The data of the execution |
Emitted whenever an auto moderation rule is created. This event requires the permission.
Name | Type | Optional | Description |
---|---|---|---|
autoModerationRule | AutoModerationRule | No | The created auto moderation rule |
Emitted whenever an auto moderation rule is deleted. This event requires the permission.
Name | Type | Optional | Description |
---|---|---|---|
autoModerationRule | AutoModerationRule | No | The deleted auto moderation rule |
Emitted whenever an auto moderation rule gets updated. This event requires the permission.
Name | Type | Optional | Description |
---|---|---|---|
oldAutoModerationRule | AutoModerationRule | No | The auto moderation rule before the update |
newAutoModerationRule | AutoModerationRule | No | The auto moderation rule after the update |
Emitted whenever a guild channel is created.
Name | Type | Optional | Description |
---|---|---|---|
channel | GuildChannel | No | The channel that was created |
Emitted whenever a channel is deleted.
Name | Type | Optional | Description |
---|---|---|---|
channel | DMChannelGuildChannel | No | The channel that was deleted |
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.
Name | Type | Optional | Description |
---|---|---|---|
channel | TextBasedChannels | No | The channel that the pins update occurred in |
time | Date | No | The time of the pins update |
Emitted whenever a channel is updated - e.g. name change, topic change, channel type change.
Name | Type | Optional | Description |
---|---|---|---|
oldChannel | DMChannelGuildChannel | No | The channel before the update |
newChannel | DMChannelGuildChannel | No | The channel after the update |
Emitted for general debugging information.
Name | Type | Optional | Description |
---|---|---|---|
info | string | No | The debug information |
Emitted whenever a custom emoji is created in a guild.
Name | Type | Optional | Description |
---|---|---|---|
emoji | GuildEmoji | No | The emoji that was created |
Emitted whenever a custom emoji is deleted in a guild.
Name | Type | Optional | Description |
---|---|---|---|
emoji | GuildEmoji | No | The emoji that was deleted |
Emitted whenever a custom emoji is updated in a guild.
Name | Type | Optional | Description |
---|---|---|---|
oldEmoji | GuildEmoji | No | The old emoji |
newEmoji | GuildEmoji | No | The new emoji |
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](https://nodejs.org/api/events.html#capture-rejections-of-promises) for details.Name | Type | Optional | Description |
---|---|---|---|
error | Error | No | The error encountered |
Emitted whenever a guild audit log entry is created.
Name | Type | Optional | Description |
---|---|---|---|
auditLogEntry | GuildAuditLogsEntry | No | The entry that was created |
guild | Guild | No | The guild where the entry was created |
Emitted whenever a guild becomes available.
Name | Type | Optional | Description |
---|---|---|---|
guild | Guild | No | The guild that became available |
Emitted whenever a member is banned from a guild.
Name | Type | Optional | Description |
---|---|---|---|
ban | GuildBan | No | The ban that occurred |
Emitted whenever a member is unbanned from a guild.
Name | Type | Optional | Description |
---|---|---|---|
ban | GuildBan | No | The ban that was removed |
Emitted whenever the client joins a guild.
Name | Type | Optional | Description |
---|---|---|---|
guild | Guild | No | The created guild |
Emitted whenever a guild kicks the client or the guild is deleted/left.
Name | Type | Optional | Description |
---|---|---|---|
guild | Guild | No | The guild that was deleted |
Emitted whenever a guild integration is updated
Name | Type | Optional | Description |
---|---|---|---|
guild | Guild | No | The guild whose integrations were updated |
Emitted whenever a user joins a guild.
Name | Type | Optional | Description |
---|---|---|---|
member | GuildMember | No | The member that has joined a guild |
Emitted whenever a member becomes available.
Name | Type | Optional | Description |
---|---|---|---|
member | GuildMember | No | The member that became available |
Emitted whenever a member leaves a guild, or is kicked.
Name | Type | Optional | Description |
---|---|---|---|
member | GuildMember | No | The member that has left/been kicked from the guild |
Emitted whenever a chunk of guild members is received (all members come from the same guild).
Name | Type | Optional | Description |
---|---|---|---|
members | Collection<Snowflake, GuildMember> | No | The members in the chunk |
guild | Guild | No | The guild related to the member chunk |
chunk | GuildMembersChunk | No | Properties of the received chunk |
Emitted whenever a guild member changes - i.e. new role, removed role, nickname.
Name | Type | Optional | Description |
---|---|---|---|
oldMember | GuildMember | No | The member before the update |
newMember | GuildMember | No | The member after the update |
Emitted whenever a guild scheduled event is created.
Name | Type | Optional | Description |
---|---|---|---|
guildScheduledEvent | GuildScheduledEvent | No | The created guild scheduled event |
Emitted whenever a guild scheduled event is deleted.
Name | Type | Optional | Description |
---|---|---|---|
guildScheduledEvent | GuildScheduledEvent | No | The deleted guild scheduled event |
Emitted whenever a guild scheduled event gets updated.
Name | Type | Optional | Description |
---|---|---|---|
oldGuildScheduledEvent | GuildScheduledEvent | No | The guild scheduled event object before the update |
newGuildScheduledEvent | GuildScheduledEvent | No | The guild scheduled event object after the update |
Emitted whenever a user subscribes to a guild scheduled event
Name | Type | Optional | Description |
---|---|---|---|
guildScheduledEvent | GuildScheduledEvent | No | The guild scheduled event |
user | User | No | The user who subscribed |
Emitted whenever a user unsubscribes from a guild scheduled event
Name | Type | Optional | Description |
---|---|---|---|
guildScheduledEvent | GuildScheduledEvent | No | The guild scheduled event |
user | User | No | The user who unsubscribed |
Emitted when an interaction is created.
Name | Type | Optional | Description |
---|---|---|---|
interaction | BaseInteraction | No | The interaction which was created |
Emitted when an invite is created. This event requires the permission for the channel.
Name | Type | Optional | Description |
---|---|---|---|
invite | Invite | No | The invite that was created |
Emitted when an invite is deleted. This event requires the permission for the channel.
Name | Type | Optional | Description |
---|---|---|---|
invite | Invite | No | The invite that was deleted |
Emitted whenever a message is created.
Name | Type | Optional | Description |
---|---|---|---|
message | Message | No | The created message |
Emitted whenever a message is deleted.
Name | Type | Optional | Description |
---|---|---|---|
message | Message | No | The deleted message |
Emitted whenever messages are deleted in bulk.
Name | Type | Optional | Description |
---|---|---|---|
messages | Collection<Snowflake, Message> | No | The deleted messages, mapped by their id |
channel | GuildTextBasedChannel | No | The channel that the messages were deleted in |
Emitted whenever a reaction is added to a cached message.
Name | Type | Optional | Description |
---|---|---|---|
messageReaction | MessageReaction | No | The reaction object |
user | User | No | The user that applied the guild or reaction emoji |
Emitted whenever a reaction is removed from a cached message.
Name | Type | Optional | Description |
---|---|---|---|
messageReaction | MessageReaction | No | The reaction object |
user | User | No | The user whose emoji or reaction emoji was removed |
Emitted whenever all reactions are removed from a cached message.
Name | Type | Optional | Description |
---|---|---|---|
message | Message | No | The message the reactions were removed from |
reactions | Collection<(string|Snowflake), MessageReaction> | No | The cached message reactions that were removed. |
Emitted when a bot removes an emoji reaction from a cached message.
Name | Type | Optional | Description |
---|---|---|---|
reaction | MessageReaction | No | The reaction that was removed |
Emitted when the client becomes ready to start working.
Name | Type | Optional | Description |
---|---|---|---|
client | Client | No | The client |
Emitted whenever a role is created.
Name | Type | Optional | Description |
---|---|---|---|
role | Role | No | The role that was created |
Emitted whenever a guild role is deleted.
Name | Type | Optional | Description |
---|---|---|---|
role | Role | No | The role that was deleted |
Emitted when a shard's WebSocket disconnects and will no longer reconnect.
Name | Type | Optional | Description |
---|---|---|---|
event | CloseEvent | No | The WebSocket close event |
id | number | No | The shard id that disconnected |
Emitted whenever a shard's WebSocket encounters a connection error.
Name | Type | Optional | Description |
---|---|---|---|
error | Error | No | The encountered error |
shardId | number | No | The shard that encountered this error |
Emitted when a shard turns ready.
Name | Type | Optional | Description |
---|---|---|---|
id | number | No | The shard id that turned ready |
unavailableGuilds | Set<Snowflake> | No | Set of unavailable guild ids, if any |
Emitted when a shard is attempting to reconnect or re-identify.
Name | Type | Optional | Description |
---|---|---|---|
id | number | No | The shard id that is attempting to reconnect |
Emitted when a shard resumes successfully.
Name | Type | Optional | Description |
---|---|---|---|
id | number | No | The shard id that resumed |
replayedEvents | number | No | The amount of replayed events |
Emitted whenever a stage instance is created.
Name | Type | Optional | Description |
---|---|---|---|
stageInstance | StageInstance | No | The created stage instance |
Emitted whenever a stage instance is deleted.
Name | Type | Optional | Description |
---|---|---|---|
stageInstance | StageInstance | No | The deleted stage instance |
Emitted whenever a stage instance gets updated - e.g. change in topic or privacy level
Name | Type | Optional | Description |
---|---|---|---|
oldStageInstance | StageInstance | No | The stage instance before the update |
newStageInstance | StageInstance | No | The stage instance after the update |
Emitted whenever a custom sticker is created in a guild.
Name | Type | Optional | Description |
---|---|---|---|
sticker | Sticker | No | The sticker that was created |
Emitted whenever a custom sticker is deleted in a guild.
Name | Type | Optional | Description |
---|---|---|---|
sticker | Sticker | No | The sticker that was deleted |
Emitted whenever a thread is created or when the client user is added to a thread.
Name | Type | Optional | Description |
---|---|---|---|
thread | ThreadChannel | No | The thread that was created |
newlyCreated | boolean | No | Whether the thread was newly created |
Emitted whenever a thread is deleted.
Name | Type | Optional | Description |
---|---|---|---|
thread | ThreadChannel | No | The thread that was deleted |
Emitted whenever the client user gains access to a text or news channel that contains threads
Name | Type | Optional | Description |
---|---|---|---|
threads | Collection<Snowflake, ThreadChannel> | No | The threads that were synced |
guild | Guild | No | The guild that the threads were synced in |
Emitted whenever members are added or removed from a thread. This event requires the privileged gateway intent.
Name | Type | Optional | Description |
---|---|---|---|
addedMembers | Collection<Snowflake, ThreadMember> | No | The members that were added |
removedMembers | Collection<Snowflake, ThreadMember> | No | The members that were removed |
thread | ThreadChannel | No | The thread where members got updated |
Emitted whenever the client user's thread member is updated.
Name | Type | Optional | Description |
---|---|---|---|
oldMember | ThreadMember | No | The member before the update |
newMember | ThreadMember | No | The member after the update |
Emitted whenever a thread is updated - e.g. name change, archive state change, locked state change.
Name | Type | Optional | Description |
---|---|---|---|
oldThread | ThreadChannel | No | The thread before the update |
newThread | ThreadChannel | No | The thread after the update |
Emitted whenever a user starts typing in a channel.
Name | Type | Optional | Description |
---|---|---|---|
typing | Typing | No | The typing state |
Emitted whenever a user's details (e.g. username) are changed. Triggered by the Discord gateway events UserUpdate, GuildMemberUpdate, and PresenceUpdate.
Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.
Name | Type | Optional | Description |
---|---|---|---|
oldState | VoiceState | No | The voice state before the update |
newState | VoiceState | No | The voice state after the update |
Emitted whenever a channel has its webhooks changed.
Name | Type | Optional | Description |
---|---|---|---|
channel | TextChannelNewsChannelVoiceChannelStageChannelForumChannelMediaChannel | No | The channel that had a webhook update |
Use webhooksUpdate instead.
Deprecated
Name | Type | Optional | Description |
---|---|---|---|
channel | TextChannelNewsChannelVoiceChannelStageChannelForumChannelMediaChannel | No | The channel that had a webhook update |
All of the BaseChannels that the client is currently handling, mapped by their ids - as long as sharding isn't being used, this will be *every* channel in *every* guild the bot 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.
All of the guilds the client is currently handling, mapped by their ids - as long as sharding isn't being used, this will be *every* guild the bot is a member of
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)
The REST manager of the client
Inherited from BaseClientShard helpers for the client (only if the process was spawned from a ShardingManager)
Authorization token for the logged in bot. If present, this defaults to
process.env.DISCORD_TOKEN
when instantiating the client This should be kept private at all times.How long it has been since the client last entered the Ready state in milliseconds
All of the User objects that have been cached at any point, mapped by their ids
The WebSocket manager of the client
Deletes a webhook.
Name | Type | Optional | Description |
---|---|---|---|
id | Snowflake | No | The webhook's id |
options | WebhookDeleteOptions | Yes | Options for deleting the webhook |
Logs out, terminates the connection to Discord, and destroys the client.
Obtains a guild preview from Discord, available for all guilds the bot is in and all Discoverable guilds.
Name | Type | Optional | Description |
---|---|---|---|
guild | GuildResolvable | No | The guild to fetch the preview for |
Obtains a template from Discord.
Name | Type | Optional | Description |
---|---|---|---|
template | GuildTemplateResolvable | No | Template code or URL |
Obtains the widget data of a guild from Discord, available for guilds with the widget enabled.
Name | Type | Optional | Description |
---|---|---|---|
guild | GuildResolvable | No | The guild to fetch the widget data for |
Obtains an invite from Discord.
Name | Type | Optional | Description |
---|---|---|---|
invite | InviteResolvable | No | Invite code or URL |
options | ClientFetchInviteOptions | Yes | Options for fetching the invite |
Use fetchStickerPacks instead.
Deprecated
Obtains a sticker from Discord.
Name | Type | Optional | Description |
---|---|---|---|
id | Snowflake | No | The sticker's id |
Obtains the list of available sticker packs.
Obtains the available voice regions from Discord.
Obtains a webhook from Discord.
Name | Type | Optional | Description |
---|---|---|---|
id | Snowflake | No | The webhook's id |
token | string | Yes | Token for the webhook |
Generates a link that can be used to invite the bot to a guild.
Name | Type | Optional | Description |
---|---|---|---|
options | InviteGenerationOptions | Yes | Options for the invite |
Returns whether the client has logged in, indicative of being able to access properties such as
user
and application
.Logs the client in, establishing a WebSocket connection to Discord.
Returns
Token of the account usedName | Type | Optional | Description |
---|---|---|---|
token | string | Yes | Token of the account to log in with |
Name | Type | Optional | Description |
---|---|---|---|
event | K | No | None |
listener | (...args: ClientEvents[K]) => Awaitable<void> | No | None |
Name | Type | Optional | Description |
---|---|---|---|
event | K | No | None |
listener | (...args: ClientEvents[K]) => Awaitable<void> | No | None |
Name | Type | Optional | Description |
---|---|---|---|
event | K | No | None |
listener | (...args: ClientEvents[K]) => Awaitable<void> | No | None |