Skip to content

Client

Client ⇐ EventEmitter

Represents a Discord client.

Kind: global class
Extends: EventEmitter

new Client([options])

ParamTypeDefaultDescription
[options]ObjectThe options to set for the client.
[options.intents]Array.<String>Intents.Flags.GuildsThe intents to use for the client.
options.tokenStringThe bot token to use for authorization.
[options.presence]ObjectThe presence options for the client.
[options.maxShards]Number1The maximum number of shards for the client.
[options.shardId]Number0The shard ID for the client.
[options.version]String”10”The API version to use for the client.
[options.encoding]String”json”The encoding to use for the client.
[options.timeout]Number15000The timeout for REST requests.
[options.restRequestTimeout]Number15000The timeout for REST requests in milliseconds.
[options.restReadyTimeout]Number2000The timeout for the REST ready event in milliseconds.
[options.partials]Array.<String>[]The partials to use for the client.

client.api ⇒ REST

Getter method that returns a new instance of the REST class with the token set.

Kind: instance property of Client
Returns: REST - - A new instance of the REST class with the token set.

client.cdn ⇒

The function returns the value of the CDN variable.

Kind: instance property of Client
Returns: The CDN property.

client.fetchInvite(invite, query) ⇒ Promise.<Invite>

Fetches an invitation using the provided invite code and query parameters.

Kind: instance method of Client
Returns: Promise.<Invite> - A promise that resolves to an Invite object representing the fetched invitation.
Throws:

  • RangeError If no invitation code is specified.
ParamTypeDescription
invitestring | objectThe invitation code or an object containing the invite code.
queryobjectThe query parameters to include in the request.

client.fetchPreview(guild) ⇒ Promise.<GuildPreview>

Fetches the preview information for a guild.

Kind: instance method of Client
Returns: Promise.<GuildPreview> - - A promise that resolves to a GuildPreview object containing the preview information.

ParamTypeDescription
guildstring | GuildThe guild ID or guild object for which to fetch the preview.

client.fetchGuildWidget(guild) ⇒ Promise.<GuildWidget>

Fetches the guild widget for the specified guild.

Kind: instance method of Client
Returns: Promise.<GuildWidget> - - A promise that resolves to a GuildWidget object representing the guild widget.

ParamTypeDescription
guildstring | GuildThe guild ID or guild object for which to fetch the widget.

client.fetchVoiceRegions() ⇒ Promise.<RaidenCol.<VoiceRegion>>

Fetches the voice regions from the API.

Kind: instance method of Client
Returns: Promise.<RaidenCol.<VoiceRegion>> - - A promise that resolves to a collection of VoiceRegion objects.

client.generateTemplate(code, [options]) ⇒ Promise.<Guild>

Generates a template using the provided code and options.

Kind: instance method of Client
Returns: Promise.<Guild> - A promise that resolves with the created guild.
Throws:

  • RangeError If the server template code is not provided.
ParamTypeDescription
codestring | objectThe code or URL of the server template.
[options]objectAdditional options for generating the template.

client.generateInvite([options]) ⇒ string | undefined

Generates an invite URL for the bot with the specified options.

Kind: instance method of Client
Returns: string | undefined

ParamTypeDescription
[options]ObjectThe options for generating the invite URL.
[options.scopes]Array.<string>The scopes to request from the user.
[options.permissions]Array.<string>The permissions to request from the user.
[options.guildSelect]booleanWhether to enable guild selection in the invite flow.
[options.guild]string | GuildThe guild to pre-select in the invite flow.
[options.responseType]stringThe response type to use for the invite.

client.debug(message) ⇒

Emits a debug event with the given message.

Kind: instance method of Client
Returns: None

ParamTypeDescription
messageanyThe debug message to emit.

client.fetchSticker(sticker) ⇒ Promise.<Sticker>

Fetches a sticker from the server.

Kind: instance method of Client
Returns: Promise.<Sticker> - - A promise that resolves to a Sticker object.

ParamTypeDescription
stickerstring | StickerThe sticker ID or the sticker object.

client.fetchNitroPacks() ⇒ Promise.<RaidenCol>

Fetches the Nitro Packs from the API.

Kind: instance method of Client
Returns: Promise.<RaidenCol> - - A promise that resolves to a RaidenCol object containing the fetched sticker packs.
Throws:

  • Error - If there is an error fetching the sticker packs.

client.fetchGuildTemplate(code) ⇒ Promise.<GuildTemplate>

Fetches a guild template from the server using the provided code.

Kind: instance method of Client
Returns: Promise.<GuildTemplate> - A promise that resolves to a GuildTemplate object.
Throws:

  • RangeError If the server template code is not provided.
ParamTypeDescription
codestringThe code of the guild template to fetch.

Client.generateTemplateGuild(o) ⇒ Object

Generates a template guild object with optional properties.

Kind: static method of Client
Returns: Object - - The generated guild object with optional properties.

ParamTypeDescription
oObjectAn object containing optional properties for the guild.
o.namestringThe name of the guild. If not provided, it will be set to undefined.
o.iconstringThe icon of the guild. If provided, it will be converted to a base64 string.

Client.transformInviteOptions(o) ⇒ Object

Transforms the given invite options object into a new object with specific properties.

Kind: static method of Client
Returns: Object - - The transformed invite options object.

ParamTypeDescription
oObjectThe invite options object.
[o.withCounts]booleanWhether to include counts in the invite.
[o.withExpiration]booleanWhether to include expiration in the invite.
[o.guildScheduledEvent]string | undefinedThe ID of the guild scheduled event.

Client.transformPresence([presence]) ⇒ Object

Transforms a presence object into a new format.

Kind: static method of Client
Returns: Object - - The transformed presence object.

ParamTypeDescription
[presence]ObjectThe presence object to transform.

Client.transformActivities(activities) ⇒ Object

Transforms the activities object into a new format.

Kind: static method of Client
Returns: Object - - The transformed activities object.

  • name: The name of the activity. If not provided, it will be set to undefined.
  • type: The type of the activity. If not provided or not a string, it will be set to 0.
  • url: The URL of the activity. If not provided, it will be set to undefined.
ParamTypeDescription
activitiesObjectThe activities object to transform.