Client
Client ⇐ EventEmitter
Represents a Discord client.
Kind: global class
Extends: EventEmitter
- Client ⇐
EventEmitter
- new Client([options])
- instance
- .api ⇒
REST
- .cdn ⇒
- .fetchInvite(invite, query) ⇒
Promise.<Invite>
- .fetchPreview(guild) ⇒
Promise.<GuildPreview>
- .fetchGuildWidget(guild) ⇒
Promise.<GuildWidget>
- .fetchVoiceRegions() ⇒
Promise.<RaidenCol.<VoiceRegion>>
- .generateTemplate(code, [options]) ⇒
Promise.<Guild>
- .generateInvite([options]) ⇒
string
|undefined
- .debug(message) ⇒
- .fetchSticker(sticker) ⇒
Promise.<Sticker>
- .fetchNitroPacks() ⇒
Promise.<RaidenCol>
- .fetchGuildTemplate(code) ⇒
Promise.<GuildTemplate>
- .api ⇒
- static
- .generateTemplateGuild(o) ⇒
Object
- .transformInviteOptions(o) ⇒
Object
- .transformPresence([presence]) ⇒
Object
- .transformActivities(activities) ⇒
Object
- .generateTemplateGuild(o) ⇒
new Client([options])
Param | Type | Default | Description |
---|---|---|---|
[options] | Object | The options to set for the client. | |
[options.intents] | Array.<String> | Intents.Flags.Guilds | The intents to use for the client. |
options.token | String | The bot token to use for authorization. | |
[options.presence] | Object | The presence options for the client. | |
[options.maxShards] | Number | 1 | The maximum number of shards for the client. |
[options.shardId] | Number | 0 | The 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] | Number | 15000 | The timeout for REST requests. |
[options.restRequestTimeout] | Number | 15000 | The timeout for REST requests in milliseconds. |
[options.restReadyTimeout] | Number | 2000 | The 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.
Param | Type | Description |
---|---|---|
invite | string | object | The invitation code or an object containing the invite code. |
query | object | The 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.
Param | Type | Description |
---|---|---|
guild | string | Guild | The 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.
Param | Type | Description |
---|---|---|
guild | string | Guild | The 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.
Param | Type | Description |
---|---|---|
code | string | object | The code or URL of the server template. |
[options] | object | Additional 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
Param | Type | Description |
---|---|---|
[options] | Object | The 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] | boolean | Whether to enable guild selection in the invite flow. |
[options.guild] | string | Guild | The guild to pre-select in the invite flow. |
[options.responseType] | string | The 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
Param | Type | Description |
---|---|---|
message | any | The 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.
Param | Type | Description |
---|---|---|
sticker | string | Sticker | The 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.
Param | Type | Description |
---|---|---|
code | string | The 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.
Param | Type | Description |
---|---|---|
o | Object | An object containing optional properties for the guild. |
o.name | string | The name of the guild. If not provided, it will be set to undefined. |
o.icon | string | The 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.
Param | Type | Description |
---|---|---|
o | Object | The invite options object. |
[o.withCounts] | boolean | Whether to include counts in the invite. |
[o.withExpiration] | boolean | Whether to include expiration in the invite. |
[o.guildScheduledEvent] | string | undefined | The 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.
Param | Type | Description |
---|---|---|
[presence] | Object | The 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.
Param | Type | Description |
---|---|---|
activities | Object | The activities object to transform. |