Skip to main content

Class: Client

Hierarchy​

  • EventEmitter

    ↳ Client

Constructors​

constructor​

• new Client(options)

Parameters​

NameTypeDescription
optionsClientOptionsoptions 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​

NameType
pingnumber

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​

NameType
pingnumber

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​

NameTypeDefault valueDescription
commandsApplicationCommandBase[]undefineda list of command object
cache?booleantrueset 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​

NameTypeDefault valueDescription
guildIdstringundefinedthe id of the guild
commandsApplicationCommandBase[]undefineda list of command object
cache?booleantrueset commands to cache

Returns​

Promise<ApplicationCommand[]>

Defined in​

packages/libcord/src/Client.ts:783


connect​

▸ connect(token): Client

connect the bot to discord

Parameters​

NameType
tokenstring

Returns​

Client

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​

NameTypeDefault valueDescription
dataApplicationCommandBase | ApplicationCommandBase[]undefineda base object of the command or an array of the commands
cache?booleantrueset the command to cache

Returns​

Promise<ApplicationCommand | ApplicationCommand[]>

Defined in​

packages/libcord/src/Client.ts:445


createDM​

▸ createDM(userId): Promise<PrivateChannel>

Parameters​

NameType
userIdstring

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​

NameTypeDefault valueDescription
guildIdstringundefinedthe id of the guild
dataApplicationCommandBase | ApplicationCommandBase[]undefineda base object of the command, or an array of commands
cache?booleantrueset 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​

NameTypeDescription
commandIdstringthe 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​

NameTypeDescription
guildIdstringthe id of the guild
commandIdstringthe id of the command

Returns​

Promise<void>

Defined in​

packages/libcord/src/Client.ts:760


destroy​

▸ destroy(): Client

Returns​

Client

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​

NameTypeDefault valueDescription
commandIdstringundefinedthe id of the command
dataEditApplicationCommandOptionsundefinedoptions to edit
cache?booleantrueset/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​

NameTypeDefault valueDescription
guildIdstringundefinedthe id of the guild
commandIdstringundefinedthe id of the command
dataEditApplicationCommandOptionsundefinedoptions to edit
cache?booleantrueset/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​

NameType
Kextends never

Parameters​

NameTypeDescription
eventKThe typed event name to emit.
...argsParameters<{}[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​

NameType
Kextends never

Parameters​

NameTypeDescription
eventKThe typed event name to emit.
...argsParameters<{}[K]>The arguments to pass to the typed listeners.

Returns​

Client

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​

NameTypeDefault valueDescription
commandIdstringundefinedthe id of the command
checkCache?booleantruecheck if the command are already in the cache
cache?booleantrueset 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​

NameTypeDefault valueDescription
cache?booleantrueset 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​

NameTypeDefault value
idstringundefined
checkCachebooleantrue
setToCachebooleantrue

Returns​

Promise<undefined | VoiceChannel | TextChannel | CategoryChannel | PrivateChannel>

Defined in​

packages/libcord/src/Client.ts:342


fetchGuild​

▸ fetchGuild(id, checkCache?, setToCache?): Promise<Guild>

Parameters​

NameTypeDefault value
idstringundefined
checkCachebooleantrue
setToCachebooleantrue

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​

NameTypeDefault valueDescription
guildIdstringundefinedthe id of the guild
commandIdstringundefinedthe id of the command
checkCache?booleantruecheck if command are already in cache
cache?booleantrueset 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​

NameTypeDefault valueDescription
guildIDstringundefinedthe id of the guild
cache?booleantrueset 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​

NameTypeDefault value
guildIdstringundefined
limitnumber100
setToCachebooleantrue
afternumber0

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​

NameType
Kextends never

Parameters​

NameTypeDescription
eventKThe typed event name.
listener{}[K]The typed event listener function.

Returns​

Client

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​

NameType
Kextends never

Parameters​

NameTypeDescription
eventKThe typed event name.

Returns​

Client

Inherited from​

EventEmitter.off

Defined in​

packages/libcord/src/utils/EventEmitter.ts:74

▸ off(): Client

Remove all events from the event listener.

Returns​

Client

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​

NameType
Kextends never

Parameters​

NameTypeDescription
eventKThe typed event name to listen for.
listener{}[K]The typed listener function.

Returns​

Client

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​

NameType
Kextends never

Parameters​

NameTypeDescription
eventKThe typed event name.
...argsParameters<{}[K]>The arguments to pass to the typed listeners.

Returns​

Client

Inherited from​

EventEmitter.queue

Defined in​

packages/libcord/src/utils/EventEmitter.ts:170


toJSON​

▸ toJSON(space?): string

Parameters​

NameTypeDefault value
spacenumber1

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​

NameType
event"raw" | RAW
listener(eventName: string, data: any) => void

Returns​

Client

Overrides​

EventEmitter.on

Defined in​

packages/libcord/src/Client.ts:89

▸ on(event, listener): Client

emitted when the client is ready Client#ready

Parameters​

NameType
eventREADY | "ready"
listener() => void

Returns​

Client

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​

NameType
eventMESSAGE | "messageCreate"
listener(message: Message) => void | Promise<void>

Returns​

Client

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​

NameType
eventINTERACTION_CREATE | "interactionCreate"
listener(interaction: CommandInteraction | Interaction | MessageContextMenuInteraction) => void | Promise<void>

Returns​

Client

Overrides​

EventEmitter.on

Defined in​

packages/libcord/src/Client.ts:110

▸ on(event, listener): Client

emitted when theres a thread creator Client#threadCreate

Parameters​

NameType
eventTHREAD_CREATE | "threadCreate"
listener(thread: PrivateThread | PublicThread) => void

Returns​

Client

Overrides​

EventEmitter.on

Defined in​

packages/libcord/src/Client.ts:124

▸ on(event, listener): Client

emitted when theres a thread deleted Client#threadDelete

Parameters​

NameType
eventTHREAD_DELETE | "threadDelete"
listener(thread: PrivateThread | PublicThread) => void

Returns​

Client

Overrides​

EventEmitter.on

Defined in​

packages/libcord/src/Client.ts:133

▸ on(event, listener): Client

emitted when there is an error Client#error

Parameters​

NameType
event"error" | ERROR
listener(error: Error) => void

Returns​

Client

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​

NameType
eventGUILD_CREATE | "guildCreate"
listener(guild: Guild) => void

Returns​

Client

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​

NameType
eventGUILD_DELETE | "guildDelete"
listener(guild: Guild) => void

Returns​

Client

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​

NameType
eventCHANNEL_CREATE | "channelCreate"
listener(channel: GuildChannel) => void

Returns​

Client

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​

NameType
eventCHANNEL_DELETE | "channelDelete"
listener(channel: GuildChannel) => void

Returns​

Client

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​

NameType
eventCHANNEL_EDIT | "channelUpdate"
listener(channel: GuildChannel) => void

Returns​

Client

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​

NameType
eventROLE_CREATE | "roleCreate"
listener(role: Role) => void

Returns​

Client

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​

NameType
eventROLE_EDIT | "roleUpdate"
listener(role: Role) => void

Returns​

Client

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​

NameType
eventROLE_DELETE | "roleDelete"
listener(role: Role) => void

Returns​

Client

Overrides​

EventEmitter.on

Defined in​

packages/libcord/src/Client.ts:206