Member class

The Member class extends the Zyno Bot Addons User class.

const member = new Member(guildMember: GuildMember, addon: Addon);

constructor

The constructor of the Member class requires two arguments. The first argument must be an instance of the Discord.js GuildMember class and provides the data of the member. The second argument must be an instance of the Zyno Bot Addons Addon class and defines the addon where the member class should be created for.

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.

guild

An instance of the Guild class and defines the guild the member is active in.

guildId

The id of the guild the member is active in.

roles

An instance of the Save class and provides the roles the member has.

Save<roleId, Role>

nickname

The nickname that has been set for the member in the guild. If no nickname has been set, this will result in a value of null.

displayName

The name that is visible in the guild for this member. If a nickname is set, this will be their nickname. Otherwise this will be their username.

permissions

An instance of the Discord.js PermissionsBitField class which provides which permissions the member has.

color

An object which provides the color codes of the color of the highest role the member has.

{
    hex: string;
    base: number;
}

joined

An instance of the built-in NodeJS Date class which represents the time the member joined the Discord server.

joinedTimestamp

A number which represents the timestamp of the time when the member joined the Discord server.

manageable

A boolean which defines whether the bot is higher in terms of hierarchy according to the role position and ownership of the Discord server.

moderatable

A boolean which defines wheter the bot can moderate the member or not.

bannable

A boolean which defines whether the member can be banned or not.

kickable

A boolean which defines whether the member can be kicked or not.

voiceConnected

A boolean which defines whether the member is currently connected to a voice channel or not.

voice

An instance of the VoiceState class which defines the current voice state of the member.

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.

getInviteInfo

member.getInviteInfo() : object;

Provides the information about the amount of members the member has invited, how many have left and by whom the member was invited. The function will return the following object:

{
    invitedBy?: Member; // The member who invited this member
    invites: number; // The total amount of invited members by this member
    leaves: number; // The amount of members who were invited by this member who left
    total: number; // The total amount of invited members by this member subtracted with the amount that left
}

getWarns

member.getWarns() : [object];

Gets the warns the member has received in the guild. The function returns an array which includes objects which represent the warn.

{
    warnedBy?: Member; // The member who warned the member
    reason: string; // The reason for the warn
    warnedAt: Date; // The time of the warn as an instance of the built-in NodeJS Date class.
    warnedAtTimestamp: number; // The time of the warn as a timestamp
}

getTickets

member.getTickets() : Save<string, TextChannel>;

Gets the open tickets of the member in the guild. The funcntion returns an instance of the Save class which provides the ticket channels.

Save<channelId, TextChannel>

getEconomy

member.getEconomy() : EconomyBalance;

Gets the economy balance of the member. The function returns an instance of the EconomyBalance class where it's possible to view and edit the balances.

getLevel

member.getLevel() : Level;

Gets the level information of the member. The function returns an instance of the Level class where it's possible to view and edit level statistics of the member.

setTimeout

member.setTimeout(dateResolvable: Date | number | string, reason?: string) : Promise<Member>;

Gives the member a timeout for a certain amount of time. The function returns a Promise which returns an instannce of the Member class with the updated data once the timeout has been given.

ArgumentDescription

dateResolvable

The duration of the timeout the member receives. This must be a number which defines the time in miliseconds, an instance of the Date class where the timestamp gets substracted of the current timestamp and the difference is used as the slow mode time or a string which defines the time like 1 hour.

reason

The reason you want to give the member a timeout. This must be a string between 1-512 characters, but is not required.

removeTimeout

member.removeTimeout(reason?: string) : Promise<Member>;

Removes the timeout of the member if the member has a timeout. The function returns a Promise which returns an instance of the Member class with the updated data once the timeout has been removed.

ArgumentDescription

reason

The reason you want to remove the member a timeout. This must be a string between 1-512 characters, but is not required.

hasTimeout

member.hasTimeout() : boolean;

Returns a boolean which defines whether the member has a timeout or not.

timeoutUntil

member.timeoutUntil() : boolean;

Returns a number which represents the timestamp of the time when the timeout of a member ends. If the member doesn't have a timeout, the function will return a value of null.

kick

member.kick(reason?: string) : Promise<Member>;

Kicks the member from the guild. The function returns a Promise which returns an instance of the Member class with the updated data of the member once the member has been kicked.

ArgumentDescription

reason

The reason you want to kick the member. This must be a string between 1-512 characters, but is not required.

ban

member.ban(options?: object) : Promise<Member>;

Bans the member from the guild. The function returns a Promise which returns an instance of the Member class with the updated data of the member once the member has been banned.

ArgumentDescription

options

An object which provides the ban information.

The options object may contain the following information:

  • reason: The reason you want to ban the member. This must be a string between 1-512 characters.

  • deleteMessages: The time frame where the messages sent by the member should be deleted. The max time frame is 1 week. This must be a number which defines the time in miliseconds, an instance of the Date class where the timestamp gets substracted of the current timestamp and the difference is used as the slow mode time or a string which defines the time like 1 hour.

update

member.update() : Promise<Member>;

Updates the member in case changes have been made to it. The function returns a Promise which returns an instance of the Member class with the updated data once the member has been updated.

addRole

member.addRole(role: string | Role | [string | Role], reason?: string) : Promise<Member>;

Adds a role or multiple roles to the member. The function returns a Promise which returns an instance of the Member class with the updated data once the roles have been given to the member.

ArgumentDescription

role

A string which represents a role id, instance of the Role class or an array with a string which represents a role id or an instance of the Role class which represents the role(s) the member should receive.

reason

The reason you want to give the member this role(s). This must be a string between 1-512 characters, but is not required.

removeRole

member.removeRole(role: string | Role | [string | Role], reason?: string) : Promise<Member>;

Removes a role or multiple roles from the member. The function returns a Promise which returns an instance of the Member class with the updated data once the roles have been removed from the member.

ArgumentDescription

role

A string which represents a role id, instance of the Role class or an array with a string which represents a role id or an instance of the Role class which represents the role(s) which should be removed from the member.

reason

The reason you want to remove this role(s) from the member. This must be a string between 1-512 characters, but is not required.

setRole

member.setRole(role: string | Role | [string | Role], reason?: string) : Promise<Member>;

Removes all the member's roles and adds a role or multiple roles to the member. The function returns a Promise which returns an instance of the Member class with the updated data once the roles of the member have been overwritten.

ArgumentDescription

role

A string which represents a role id, instance of the Role class or an array with a string which represents a role id or an instance of the Role class which represents the role(s) the member should have.

reason

The reason you want to overwrite the member's role(s). This must be a string between 1-512 characters, but is not required.

isBannable

member.isBannable() : boolean;

Returns a boolean which defines whether the member can be banned or not.

isKickable

member.isKickable() : boolean;

Returns a boolean which defines whether the member can be kicked or not.

isMutable

member.isMutable() : boolean;

Returns a boolean which defines whether the member can be muted or not.

Last updated