Class: Client
Hierarchy
EventEmitter
↳
Client
Constructors
constructor
• new Client(options
)
Parameters
Name | Type | Description |
---|---|---|
options | ClientOptions | options of the bot |
Inherited from
EventEmitter.constructor
Defined in
packages/libcord/src/Client.ts:268
Properties
bot
• bot: boolean
Defined in
packages/libcord/src/Client.ts:238
channels
• channels: Collection
<string
, VoiceChannel
| TextChannel
| CategoryChannel
| PrivateChannel
>
Defined in
packages/libcord/src/Client.ts:249
disableEvents
• Optional
Readonly
disableEvents: ("ApplicationCommandPermissionsUpdate"
| "ChannelCreate"
| "ChannelDelete"
| "ChannelPinsUpdate"
| "ChannelUpdate"
| "GuildBanAdd"
| "GuildBanRemove"
| "GuildCreate"
| "GuildDelete"
| "GuildEmojisUpdate"
| "GuildIntegrationsUpdate"
| "GuildMemberAdd"
| "GuildMemberRemove"
| "GuildMembersChunk"
| "GuildMemberUpdate"
| "GuildRoleCreate"
| "GuildRoleDelete"
| "GuildRoleUpdate"
| "GuildStickersUpdate"
| "GuildUpdate"
| "IntegrationCreate"
| "IntegrationDelete"
| "IntegrationUpdate"
| "InteractionCreate"
| "InviteCreate"
| "InviteDelete"
| "MessageCreate"
| "MessageDelete"
| "MessageDeleteBulk"
| "MessageReactionAdd"
| "MessageReactionRemove"
| "MessageReactionRemoveAll"
| "MessageReactionRemoveEmoji"
| "MessageUpdate"
| "PresenceUpdate"
| "StageInstanceCreate"
| "StageInstanceDelete"
| "StageInstanceUpdate"
| "Ready"
| "Resumed"
| "ThreadCreate"
| "ThreadDelete"
| "ThreadListSync"
| "ThreadMembersUpdate"
| "ThreadMemberUpdate"
| "ThreadUpdate"
| "TypingStart"
| "UserUpdate"
| "VoiceServerUpdate"
| "VoiceStateUpdate"
| "WebhooksUpdate"
| "GuildScheduledEventCreate"
| "GuildScheduledEventUpdate"
| "GuildScheduledEventDelete"
| "GuildScheduledEventUserAdd"
| "GuildScheduledEventUserRemove"
)[]
list of events that the bot don't emit
Defined in
packages/libcord/src/Client.ts:229
fetchAllMembers
• fetchAllMembers: boolean
Defined in
packages/libcord/src/Client.ts:237
gateway
• gateway: Gateway
bot gateway
Defined in
packages/libcord/src/Client.ts:224
guilds
• guilds: Collection
<string
, Guild
>
Defined in
packages/libcord/src/Client.ts:248
intents
• intents: number
int number for intents
Defined in
packages/libcord/src/Client.ts:216
options
• options: ClientOptions
the options for the client
Defined in
packages/libcord/src/Client.ts:264
presence
• presence: Presence
= {}
bot current presence
Defined in
packages/libcord/src/Client.ts:220
requestHandler
• requestHandler: RestManager
Defined in
packages/libcord/src/Client.ts:225
rest
• rest: Object
Type declaration
Name | Type |
---|---|
ping | number |
Defined in
packages/libcord/src/Client.ts:243
slashCommand
• Readonly
slashCommand: boolean
Defined in
packages/libcord/src/Client.ts:260
slashCommands
• slashCommands: Collection
<string
, ApplicationCommand
>
Defined in
packages/libcord/src/Client.ts:253
token
• token: any
Defined in
packages/libcord/src/Client.ts:235
unavailableGuilds
• unavailableGuilds: string
[] = []
Defined in
packages/libcord/src/Client.ts:255
user
• Optional
user: ClientUser
a user object of the bot
Defined in
packages/libcord/src/Client.ts:234
users
• users: Collection
<string
, User
>
Defined in
packages/libcord/src/Client.ts:247
ws
• ws: Object
Type declaration
Name | Type |
---|---|
ping | number |
Defined in
packages/libcord/src/Client.ts:240
Methods
bulkOverwriteApplicationCommands
▸ bulkOverwriteApplicationCommands(commands
, cache?
): Promise
<ApplicationCommand
[]>
Takes a list of application commands, overwriting existing commands that are registered globally for this application. Updates will be available in all guilds after 1 hour.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
commands | ApplicationCommandBase [] | undefined | a list of command object |
cache? | boolean | true | set commands to cache |
Returns
Promise
<ApplicationCommand
[]>
Defined in
packages/libcord/src/Client.ts:573
bulkOverwriteGuildApplicationCommands
▸ bulkOverwriteGuildApplicationCommands(guildId
, commands
, cache?
): Promise
<ApplicationCommand
[]>
Takes a list of application commands, overwriting existing commands for the guild.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
guildId | string | undefined | the id of the guild |
commands | ApplicationCommandBase [] | undefined | a list of command object |
cache? | boolean | true | set commands to cache |
Returns
Promise
<ApplicationCommand
[]>
Defined in
packages/libcord/src/Client.ts:783
connect
▸ connect(token
): Client
connect the bot to discord
Parameters
Name | Type |
---|---|
token | string |
Returns
Defined in
packages/libcord/src/Client.ts:302
createApplicationCommand
▸ createApplicationCommand(data
, cache?
): Promise
<ApplicationCommand
| ApplicationCommand
[]>
Create a new global command. New global commands will be available in all guilds after 1 hour, this also takes arrays
⚠ Creating a command with the same name as an existing command for your application will overwrite the old command. see discord-api-docs
Parameters
Name | Type | Default value | Description |
---|---|---|---|
data | ApplicationCommandBase | ApplicationCommandBase [] | undefined | a base object of the command or an array of the commands |
cache? | boolean | true | set the command to cache |
Returns
Promise
<ApplicationCommand
| ApplicationCommand
[]>
Defined in
packages/libcord/src/Client.ts:445
createDM
▸ createDM(userId
): Promise
<PrivateChannel
>
Parameters
Name | Type |
---|---|
userId | string |
Returns
Promise
<PrivateChannel
>
Defined in
packages/libcord/src/Client.ts:405
createGuildApplicationCommand
▸ createGuildApplicationCommand(guildId
, data
, cache?
): Promise
<ApplicationCommand
| ApplicationCommand
[]>
Create a new guild command.
⚠ Creating a command with the same name as an existing command for your application will overwrite the old command. see discord-api-docs
Parameters
Name | Type | Default value | Description |
---|---|---|---|
guildId | string | undefined | the id of the guild |
data | ApplicationCommandBase | ApplicationCommandBase [] | undefined | a base object of the command, or an array of commands |
cache? | boolean | true | set the command to cache |
Returns
Promise
<ApplicationCommand
| ApplicationCommand
[]>
Defined in
packages/libcord/src/Client.ts:633
deleteApplicationCommand
▸ deleteApplicationCommand(commandId
): Promise
<void
>
delete a global application command
Parameters
Name | Type | Description |
---|---|---|
commandId | string | the id of the command |
Returns
Promise
<void
>
Defined in
packages/libcord/src/Client.ts:556
deleteGuildApplicationCommand
▸ deleteGuildApplicationCommand(guildId
, commandId
): Promise
<void
>
delete a guild command
Parameters
Name | Type | Description |
---|---|---|
guildId | string | the id of the guild |
commandId | string | the id of the command |
Returns
Promise
<void
>
Defined in
packages/libcord/src/Client.ts:760
destroy
▸ destroy(): Client
Returns
Defined in
packages/libcord/src/Client.ts:319
editApplicationCommand
▸ editApplicationCommand(commandId
, data
, cache?
): Promise
<ApplicationCommand
>
Edit a global command. Updates will be available in all guilds after 1 hour
Parameters
Name | Type | Default value | Description |
---|---|---|---|
commandId | string | undefined | the id of the command |
data | EditApplicationCommandOptions | undefined | options to edit |
cache? | boolean | true | set/update the command to cache |
Returns
Promise
<ApplicationCommand
>
Defined in
packages/libcord/src/Client.ts:520
editGuildApplicationCommand
▸ editGuildApplicationCommand(guildId
, commandId
, data
, cache?
): Promise
<ApplicationCommand
>
Edit a guild command.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
guildId | string | undefined | the id of the guild |
commandId | string | undefined | the id of the command |
data | EditApplicationCommandOptions | undefined | options to edit |
cache? | boolean | true | set/update the command to cache |
Returns
Promise
<ApplicationCommand
>
Defined in
packages/libcord/src/Client.ts:717
emit
▸ emit<K
>(event
, ...args
): Promise
<Client
>
Emit a typed event and wait for each typed listener to return.
Type parameters
Name | Type |
---|---|
K | extends never |
Parameters
Name | Type | Description |
---|---|---|
event | K | The typed event name to emit. |
...args | Parameters <{}[K ]> | The arguments to pass to the typed listeners. |
Returns
Promise
<Client
>
Inherited from
EventEmitter.emit
Defined in
packages/libcord/src/utils/EventEmitter.ts:139
emitSync
▸ emitSync<K
>(event
, ...args
): Client
Emit a typed event without waiting for each listener to return.
Type parameters
Name | Type |
---|---|
K | extends never |
Parameters
Name | Type | Description |
---|---|---|
event | K | The typed event name to emit. |
...args | Parameters <{}[K ]> | The arguments to pass to the typed listeners. |
Returns
Inherited from
EventEmitter.emitSync
Defined in
packages/libcord/src/utils/EventEmitter.ts:112
fetchApplicationCommand
▸ fetchApplicationCommand(commandId
, checkCache?
, cache?
): Promise
<ApplicationCommand
>
fetch a global application command with the command id
Parameters
Name | Type | Default value | Description |
---|---|---|---|
commandId | string | undefined | the id of the command |
checkCache? | boolean | true | check if the command are already in the cache |
cache? | boolean | true | set the command to cache |
Returns
Promise
<ApplicationCommand
>
Defined in
packages/libcord/src/Client.ts:492
fetchApplicationCommands
▸ fetchApplicationCommands(cache?
): Promise
<ApplicationCommand
[]>
get all global bot applications commands
Parameters
Name | Type | Default value | Description |
---|---|---|---|
cache? | boolean | true | set the commands to cache |
Returns
Promise
<ApplicationCommand
[]>
a array of commands object
Defined in
packages/libcord/src/Client.ts:421
fetchChannel
▸ fetchChannel(id
, checkCache?
, setToCache?
): Promise
<undefined
| VoiceChannel
| TextChannel
| CategoryChannel
| PrivateChannel
>
Parameters
Name | Type | Default value |
---|---|---|
id | string | undefined |
checkCache | boolean | true |
setToCache | boolean | true |
Returns
Promise
<undefined
| VoiceChannel
| TextChannel
| CategoryChannel
| PrivateChannel
>
Defined in
packages/libcord/src/Client.ts:342
fetchGuild
▸ fetchGuild(id
, checkCache?
, setToCache?
): Promise
<Guild
>
Parameters
Name | Type | Default value |
---|---|---|
id | string | undefined |
checkCache | boolean | true |
setToCache | boolean | true |
Returns
Promise
<Guild
>
Defined in
packages/libcord/src/Client.ts:324
fetchGuildApplicationCommand
▸ fetchGuildApplicationCommand(guildId
, commandId
, checkCache?
, cache?
): Promise
<ApplicationCommand
>
fetch a guild command with id
Parameters
Name | Type | Default value | Description |
---|---|---|---|
guildId | string | undefined | the id of the guild |
commandId | string | undefined | the id of the command |
checkCache? | boolean | true | check if command are already in cache |
cache? | boolean | true | set the command to cache |
Returns
Promise
<ApplicationCommand
>
Defined in
packages/libcord/src/Client.ts:687
fetchGuildApplicationCommands
▸ fetchGuildApplicationCommands(guildID
, cache?
): Promise
<ApplicationCommand
[]>
get all applications commands of a guild
Parameters
Name | Type | Default value | Description |
---|---|---|---|
guildID | string | undefined | the id of the guild |
cache? | boolean | true | set the commands to cache |
Returns
Promise
<ApplicationCommand
[]>
a array of commands object
Defined in
packages/libcord/src/Client.ts:602
fetchMembers
▸ fetchMembers(guildId
, limit?
, setToCache?
, after?
): Promise
<Member
[]>
Parameters
Name | Type | Default value |
---|---|---|
guildId | string | undefined |
limit | number | 100 |
setToCache | boolean | true |
after | number | 0 |
Returns
Promise
<Member
[]>
Defined in
packages/libcord/src/Client.ts:372
off
▸ off<K
>(event
, listener
): Client
Remove a specific listener in the event emitter on a specific typed event.
Type parameters
Name | Type |
---|---|
K | extends never |
Parameters
Name | Type | Description |
---|---|---|
event | K | The typed event name. |
listener | {}[K ] | The typed event listener function. |
Returns
Inherited from
EventEmitter.off
Defined in
packages/libcord/src/utils/EventEmitter.ts:68
▸ off<K
>(event
): Client
Remove all listeners on a specific typed event.
Type parameters
Name | Type |
---|---|
K | extends never |
Parameters
Name | Type | Description |
---|---|---|
event | K | The typed event name. |
Returns
Inherited from
EventEmitter.off
Defined in
packages/libcord/src/utils/EventEmitter.ts:74
▸ off(): Client
Remove all events from the event listener.
Returns
Inherited from
EventEmitter.off
Defined in
packages/libcord/src/utils/EventEmitter.ts:79
once
▸ once<K
>(event
, listener
): Client
Listen for a typed event once.
Type parameters
Name | Type |
---|---|
K | extends never |
Parameters
Name | Type | Description |
---|---|---|
event | K | The typed event name to listen for. |
listener | {}[K ] | The typed listener function. |
Returns
Inherited from
EventEmitter.once
Defined in
packages/libcord/src/utils/EventEmitter.ts:49
queue
▸ queue<K
>(event
, ...args
): Client
The same as emitSync, but wait for each typed listener to return before calling the next typed listener.
Type parameters
Name | Type |
---|---|
K | extends never |
Parameters
Name | Type | Description |
---|---|---|
event | K | The typed event name. |
...args | Parameters <{}[K ]> | The arguments to pass to the typed listeners. |
Returns
Inherited from
EventEmitter.queue
Defined in
packages/libcord/src/utils/EventEmitter.ts:170
toJSON
▸ toJSON(space?
): string
Parameters
Name | Type | Default value |
---|---|---|
space | number | 1 |
Returns
string
Defined in
packages/libcord/src/Client.ts:808
Events
on
▸ on(event
, listener
): Client
raw packets emitted by the Gateway Client#raw
Parameters
Name | Type |
---|---|
event | "raw" | RAW |
listener | (eventName : string , data : any ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:89
▸ on(event
, listener
): Client
emitted when the client is ready Client#ready
Parameters
Name | Type |
---|---|
event | READY | "ready" |
listener | () => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:97
▸ on(event
, listener
): Client
emitted when the client receives a new Message Client#messageCreate
Parameters
Name | Type |
---|---|
event | MESSAGE | "messageCreate" |
listener | (message : Message ) => void | Promise <void > |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:102
▸ on(event
, listener
): Client
emitted when the client receives a new Message Client#messageCreate
Parameters
Name | Type |
---|---|
event | INTERACTION_CREATE | "interactionCreate" |
listener | (interaction : CommandInteraction | Interaction | MessageContextMenuInteraction ) => void | Promise <void > |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:110
▸ on(event
, listener
): Client
emitted when theres a thread creator Client#threadCreate
Parameters
Name | Type |
---|---|
event | THREAD_CREATE | "threadCreate" |
listener | (thread : PrivateThread | PublicThread ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:124
▸ on(event
, listener
): Client
emitted when theres a thread deleted Client#threadDelete
Parameters
Name | Type |
---|---|
event | THREAD_DELETE | "threadDelete" |
listener | (thread : PrivateThread | PublicThread ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:133
▸ on(event
, listener
): Client
emitted when there is an error Client#error
Parameters
Name | Type |
---|---|
event | "error" | ERROR |
listener | (error : Error ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:142
▸ on(event
, listener
): Client
emitted when the bot has joined a new server Client#guildCreate
Parameters
Name | Type |
---|---|
event | GUILD_CREATE | "guildCreate" |
listener | (guild : Guild ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:150
▸ on(event
, listener
): Client
emitted when the bot has left a server Client#guildDelete
Parameters
Name | Type |
---|---|
event | GUILD_DELETE | "guildDelete" |
listener | (guild : Guild ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:158
▸ on(event
, listener
): Client
emitted when a new channel has been created in a server Client#channelCreate
Parameters
Name | Type |
---|---|
event | CHANNEL_CREATE | "channelCreate" |
listener | (channel : GuildChannel ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:166
▸ on(event
, listener
): Client
emitted when a channel has been deleted Client#channelDelete
Parameters
Name | Type |
---|---|
event | CHANNEL_DELETE | "channelDelete" |
listener | (channel : GuildChannel ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:174
▸ on(event
, listener
): Client
emitted when a channel has been edited Client#channelUpdate
Parameters
Name | Type |
---|---|
event | CHANNEL_EDIT | "channelUpdate" |
listener | (channel : GuildChannel ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:182
▸ on(event
, listener
): Client
emitted when a role has been created Client#roleCreate
Parameters
Name | Type |
---|---|
event | ROLE_CREATE | "roleCreate" |
listener | (role : Role ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:190
▸ on(event
, listener
): Client
emitted when a role has been edited Client#roleUpdate
Parameters
Name | Type |
---|---|
event | ROLE_EDIT | "roleUpdate" |
listener | (role : Role ) => void |
Returns
Overrides
EventEmitter.on
Defined in
packages/libcord/src/Client.ts:198
▸ on(event
, listener
): Client
emitted when a role has been deleted Client#roleDelete
Parameters
Name | Type |
---|---|
event | ROLE_DELETE | "roleDelete" |
listener | (role : Role ) => void |
Returns
Overrides
EventEmitter.on