Client

Client

new Client()

Source:
Properties:
Name Type Attributes Description
channels Store

Where channels are being cached

connectedShards Store

A store of connected shards

guilds Store

Where guilds are being cached

token String

The token of the client

users Store

Where users are being cached

shards Store

A store of Shards

shardCount Number

The amount of shards to connect to Discord. ( useful for by shard status )

options Object <optional>

Options for the Discord Client

Properties
Name Type Attributes Default Description
shardCount Number | String <optional>
1

The amount of shards to use

disableEveryone Boolean <optional>
true

Whether to disable the @everyone ping

getAllMembers Boolean <optional>
false

Whether to fetch all members on each guild regardless of being offline or not

storeMessages Boolean <optional>
false

Whether to store messages in a cache, once the bot restarts the messages in the cache will be gone and can't be re-added automatically

loginDelay Number <optional>
6500

The amount of time in ms to add a delay when connecting shards

logger Boolean <optional>
false

Whether to use our custom logging

largeThreshold Number <optional>
250

The amount of members needed to consider a guild large

Extends

  • EventEmitter

Methods

createDM(user) → {Promise.<DMChannel>}

Source:

Creates a DMChannel between a user

Parameters:
Name Type Description
user Snowflake

The id of the recipient for the DM

Returns:
Type
Promise.<DMChannel>

createEmbed(channel, embed) → {Promise.<Message>}

Source:
Deprecated:
  • Use Client#sendMessage() instead.

Creates an embed to a channel

Parameters:
Name Type Description
channel Snowflake

The id of the channel to send a message to

embed Object

The embed to send

Returns:
Type
Promise.<Message>

createGuild(name, optionsopt) → {Promise.<Guild>}

Source:

Creates a guild

Parameters:
Name Type Attributes Description
name String

The name for the new guild

options Object <optional>

Options for the new guild

Properties
Name Type Attributes Description
region String <optional>

The region for the guild

icon String <optional>

A base64 128x128 jpeg image for the guild icon

Returns:
Type
Promise.<Guild>

createMessage(channel, content) → {Promise.<Message>}

Source:
Deprecated:
  • Use Client#sendMessage() instead.

Creates a message to a channel

Parameters:
Name Type Description
channel Snowflake

The id of the channel to send a message to

content String

The content to send

Returns:
Type
Promise.<Message>

customLog(type, color, message) → {Object}

Source:

Make your own log with your own type and color

Parameters:
Name Type Description
type String

The type of the log, can be anything

color String

The color of the type

message String

The message to log

Returns:
Type
Object

getUser(user) → {Promise.<User>}

Source:

Fetches the user from cache, if it doesn't exist use the REST API to fetch it and add to the cache

Parameters:
Name Type Description
user Snowflake

The id of the user to fetch

Returns:
Type
Promise.<User>

(async) initiate(token) → {Void}

Source:

This will start connecting to the gateway using the given bot token

Parameters:
Name Type Description
token String

The token of the user

Returns:
Type
Void

leaveGuild(guild) → {Promise.<Boolean>}

Source:

Makes the bot leave the guild

Parameters:
Name Type Description
guild Snowflake

The id of the guild

Returns:

Will return true if it's a success

Type
Promise.<Boolean>

log(type, message) → {Object}

Source:

Logs something to the console that is colored.

Parameters:
Name Type Description
type String

The type of the log

message String

The message to log

Returns:
Type
Object

patchMessage(channel, options) → {Promise.<Message>}

Source:

Edits a message

Parameters:
Name Type Description
channel Snowflake

The id of the channel

options Object

Options for the message editing

Properties
Name Type Description
content String

The content of the message

embed Embed

The embed for the message

message Snowflake

The id of the message

Returns:
Type
Promise.<Message>

rgbLog(type, message, optionsopt) → {Object}

Source:

Make your own log with your own type and color using RGB

Parameters:
Name Type Attributes Description
type String

The type of the log, can be anything

message String

The message to log

options Object <optional>

The options for the RGB Color

Properties
Name Type Attributes Default Description
red Number <optional>
0

The number for the color red in the rgb data

green Number <optional>
0

The number for the color green in the rgb data

blue Number <optional>
0

The number for the color blue in the rgb data

Returns:
Type
Object

sendMessage(channel, options) → {Promise.<Message>}

Source:

Sends a message to a channel

Parameters:
Name Type Description
channel Snowflake
options Object
Properties
Name Type Attributes Description
content String <optional>

The content of the message

embed Embed <optional>

The embed object of the message

Returns:
Type
Promise.<Message>

setActivity(shard, optionsopt) → {Object}

Source:

Sends an activity to the shard

Parameters:
Name Type Attributes Description
shard String

The id of the shard, or 'all' for all shards

options Object <optional>

The options for the Activity

Properties
Name Type Attributes Default Description
since Number <optional>
null

Unix time (in milliseconds) of when the client went idle, or null if the client is not idle

game Object <optional>
null

The user's new activity

Properties
Name Type Attributes Default Description
name String <optional>
null

The activity's name

type Number <optional>
0

The activity's type

url String <optional>
null

The url of the activity ( Only for game type 1 )

status String <optional>
'online'

The new status of the client

afk Boolean <optional>
false

Whether or not the client is afk

Returns:

The options for the Activity

Type
Object

spawn(id) → {Boolean}

Source:

Spawns a shard

Parameters:
Name Type Description
id Number

The id of the shard

Returns:
Type
Boolean

Events

CHANNEL_CREATE

Source:
Properties:
Type Description
TextChannel | VoiceChannel | CategoryChannel | DMChannel

Emitted once a channel has been created

CHANNEL_DELETE

Source:
Properties:
Name Type Description
channel DMChannel | TextChannel | VoiceChannel | CategoryChannel

The channel that got deleted

Emitted once a channel gets deleted

CHANNEL_UPDATE

Source:
Properties:
Name Type Description
oldChannel DMChannel | TextChannel | VoiceChannel | CategoryChannel

The old data of the channel ( Not Cached )

newChannel DMChannel | TextChannel | VoiceChannel | CategoryChannel

The new data of the channel

Emitted once a channel gets updated

GUILD_AVAILABLE

Source:
Properties:
Name Type Description
guild Guild

The guild that became available

Emitted once a guild becomes available

GUILD_CREATE

Source:
Properties:
Name Type Description
guild Guild

The guild that became available

Emitted once a bot joins a guild

GUILD_DELETE

Source:
Properties:
Name Type Description
guild Guild

Emitted once a Guild becomes Unavailable or the bot leaves a Guild

GUILD_MEMBER_ADD

Source:
Properties:
Name Type Description
member Member

The member object that joined

guild Guild

The guild the member joined

Emits once a user joins a guild

GUILD_MEMBER_REMOVE

Source:
Properties:
Name Type Description
member Member

The member object that left

guild Guild

The guild the member left

Emits once a user leaves a guild

GUILD_MEMBER_UPDATE

Source:
Properties:
Name Type Description
member Member

The new member data ( Cached )

oldMember Member

The old member data ( Partial, not cached )

Properties
Name Type Attributes Description
nick String <nullable>

The old nickname of the member

roles Store

The old roles of the member

Emits once a user joins a guild

GUILD_MEMBERS_CHUNK

Source:
Properties:
Name Type Description
guild Guild

The guild that requested for all members to be fetced

Emitted when a guild requests all members to be fetched

MESSAGE_CREATE

Source:
Properties:
Name Type Description
message Message

Emitted once a message is seen/sent

READY

Source:

Emitted once all Shards are ready

ROLE_CREATE

Source:
Properties:
Name Type Description
role Role

The role that was created

Emitted once a role is created

ROLE_DELETE

Source:
Properties:
Name Type Description
role Role

The deleted role

Emitted once a role is deleted, this also emits one or multiple Client#GUILD_MEMBER_UPDATE

ROLE_UPDATE

Source:
Properties:
Name Type Description
oldRole Role

The old role data

role Role

The new role data

Emitted once a role gets updated

SHARD_DISCONNECT

Source:
Properties:
Name Type Description
shard Shard

Partial Shard data

Properties
Name Type Description
id String

Id of the shard

description String

Description of the disconnect

reason String

Websocket reason for the disconnect

Emitted once a Shard Disconnects

SHARD_DISCONNECT_ALL

Source:
Properties:
Name Type Description
data Object

The data of the event

Properties
Name Type Description
message String

The message

Emitted once all shards disconnect

SHARD_LOADING

Source:
Properties:
Name Type Description
id String

The id of the shard

Emitted once a Shard is loading, inner data is a partial Shard Data

SHARD_READY

Source:
Properties:
Name Type Description
shard Shard

The data of the shard

Emitted once a Shard becomes ready

USER_UPDATE

Source:
Properties:
Name Type Description
oldUser User

The old data of the user ( Not present in cache )

newUser User

The new data of the user ( Present in cache )

Emitted once a User updates his/her info