User class

const user = new User(user: User, addon: Addon, loop: boolean);

constructor

The User class provides two required arguments. The first is a Discord.js user which is an instance of the User class. The second argument is the addon where to create the user for and has to be an instance of the Addon class. The third argument is a boolean which defines if the User class already reached a loop or not. If this is not the case, the User class will cache the User so you will be able to get the information later back.

Properties

id

The id of the user and is a Twitter snowflake.

string

Returns the user mention as a string.

username

The username of the user.

tag

The username with their discriminator. Only available for users who haven't changed their username yet. Otherwise their tag will be their username with the discriminator 0.

discriminator

The number behind the tag of the user. Only available for users who haven't changed their username yet. Otherwise this will return the character 0.

created

An instance of the default Date class which defines the time when the user was created.

createdTimestamp

A number which represents the timestamp of when the user was created.

bot

A boolean which defines whether the user is a bot or not.

system

A boolean which defines whether the user is the Discord system or not.

addon

The Addon class of the addon which is using the User class.

bitfield

The permissions the addon has as a bitfield number which is using the User class.

Functions

avatarURL

user.avatarURL(options?: object) : string;

Returns the url of the avatar of the user based on the image options which were provided.

ArgumentDescription

options

An object of image options which includes the criteria the avatar url has to meet.

The image options object may contain the following information:

  • dynamic: A boolean which defines whether the avatar image should be dynamic if possible or not.

  • size: A number which defines the size of the image. The size number must be a valid result of the mention math formula below with 0 <= x <= 8.

  • extension: The file extension of the image. Valid extensions are png, jpeg, jpg, webp and gif.

f(x)=162xf(x)=16*2^x

bannerURL

user.bannerURL(options?: object) : string;

Returns the url of the banner of the user based on the image options which were provided.

ArgumentDescription

options

An object of image options which includes the criteria the banner url has to meet.

The image options object may contain the following information:

  • dynamic: A boolean which defines whether the banner image should be dynamic if possible or not.

  • size: A number which defines the size of the image. The size number must be a valid result of the mention math formula below with 0 <= x <= 8.

  • extension: The file extension of the image. Valid extensions are png, jpeg, jpg, webp and gif.

f(x)=162xf(x)=16*2^x

update

user.update() : Promise<User>;

Updates the information of the user manually if the user changed something about themselves, like their username for example. The function returns a Promise which will return the User class once it's fulfilled.

sendDM

user.sendDM(...content: [string | Embed | ActionRowBuilder | ButtonBuilder | SelectMenuBuilder | object]) : Promise<Message>;

Sends a DM to the user. The function returns a Promise which returns an instance of the Message class when the DM message has been sent to the user.

ArgumentDescription

content

The content of the message the bot should send. The content must be a string, an Embed class, the ActionRowBuilder class, the ButtonBuilder class, the SelectMenuBuilder class or an object which provides the message its content.

The object of the message may contain the following information:

  • content: A string of the content of the message.

  • embeds: An array with the Embed class.

  • files: An array with a string which represents a file url or an object when uploading a file.

  • components: An array with the Discord.js ActionRowBuilder class.

The file object data may contain the following information:

  • name: The name of the file you want to upload

  • attachment: The path of the file you want to upload

  • description: The description of the file

getDMChannel

user.getDMChannel() : Promise<DMChannel>;

Gets the DM channel where you can interact with the user. The function returns a Promise which returns the DMChannel class once it's fulfilled.

getMembers

user.getMembers() : Save<string, Member>;

Returns a Save class which has all the Member classes of the user. It only shows the classes of the Member of the guilds the member and bot have in common.

Last updated