Skip to main content
Version: 0.9.0

Class: Member

Represents a member of a server on Stoat

Extends​

Constructors​

Constructor​

new Member(client, data, serverId?): Member

Parameters​

ParameterType
clientClient
data{ }
serverId?string

Returns​

Member

Overrides​

Base.constructor

Properties​

avatar​

avatar: Attachment | null = null


cachedAt​

cachedAt: number

Inherited from​

Base.cachedAt


canPublish​

canPublish: boolean = false


canRecieve​

canRecieve: boolean = false


client​

protected readonly client: Client

Inherited from​

Base.client


id​

readonly id: string

Inherited from​

Base.id


joinedAt​

joinedAt: Date


joinedTimestamp​

joinedTimestamp: number


nickname​

nickname: string | null = null


pronouns?​

optional pronouns?: string | null = null


roles​

roles: MemberRoleManager


serverId​

serverId: string


timeout​

timeout: Date | null = null

Accessors​

avatarURL​

Get Signature​

get avatarURL(): string | null

Get avatar URL for this member, or null if they don't have one.

Example​
// Get a member's avatar URL
const avatarURL = member.avatarURL;
console.log(avatarURL); // https://cdn.stoat.chat/attachments/avatars/1234567890/avatar.png
Returns​

string | null


permissions​

Get Signature​

get permissions(): Permissions

Calculates the member's total permissions using BigInt

Returns​

Permissions


roleIds​

Get Signature​

get roleIds(): string[]

Get member role IDs

Returns​

string[]


server​

Get Signature​

get server(): Server | undefined

Gets the Server object this member belongs to

Returns​

Server | undefined


user​

Get Signature​

get user(): User | undefined

Gets the global User object for this member

Returns​

User | undefined

Methods​

_clone()​

_clone(): this

Helper to quickly clone a structure

Returns​

this

Inherited from​

Base._clone


_patch()​

_patch(data, clear?): void

Parameters​

ParameterType
data{ }
clear?("Avatar" | "Pronouns" | "Nickname" | "Roles" | "Timeout" | "CanReceive" | "CanPublish" | "JoinedAt" | "VoiceChannel")[]

Returns​

void


ban()​

ban(options?): Promise<void>

Ban this member from the server.

Parameters​

ParameterTypeDescription
options?MemberBanOptionsThe options for this ban

Returns​

Promise<void>

Example​

// Ban a member with a reason and delete their messages from the last hour
await member.ban({ reason: "Spamming", deleteMessageSeconds: 3600 });

createDM()​

createDM(force?): Promise<void>

Creates a DM channel between the client's user and this member.

Parameters​

ParameterTypeDefault valueDescription
forcebooleanfalseIf true, forces the creation of a new DM channel even if one already exists.

Returns​

Promise<void>

A promise that resolves to the created DMChannel object.

Throws​

If the API request fails.

Example​

// Create a DM with this member
const dm = await member.createDM();
console.log(`DM channel ID: ${dm.id}`);

edit()​

edit(options): Promise<Member>

Edit this member.

Parameters​

ParameterTypeDescription
optionsMemberEditOptionsThe options to edit the member with (nickname, roles, timeout, etc.)

Returns​

Promise<Member>

A promise that resolves to the updated Member.


equals()​

equals(other): boolean

Compares this object with another to see if they represent the same entity.

Parameters​

ParameterType
otherstring | Base

Returns​

boolean

Inherited from​

Base.equals


kick()​

kick(): Promise<void>

Kick this member from the server.

Returns​

Promise<void>


send()​

send(options): Promise<Message>

Send a message to this member.

Parameters​

ParameterTypeDescription
optionsstring | MessageOptionsThe content or options for the message to send.

Returns​

Promise<Message>

A promise that resolves to the sent Message object.

Throws​

If the API request fails.

Example​

// Send a message to this member
const message = await member.send("Hello!");
console.log(`Sent message ID: ${message.id}`);

setNickname()​

setNickname(nickname): Promise<Member>

Parameters​

ParameterType
nicknamestring

Returns​

Promise<Member>


setTimeout()​

setTimeout(duration): Promise<void>

Timeout this member for a specified duration.

Parameters​

ParameterTypeDescription
durationnumberThe duration of the timeout in milliseconds.

Returns​

Promise<void>

Example​

// Timeout a member for 10 minutes (600,000 milliseconds)
await member.setTimeout(600000);

toString()​

toString(): string

When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.

Returns​

string

Example​

// Logs: Hello from <@01JE2MM759J5D7CHJF084R7MJ2>!
console.log(`Hello from ${member}!`);

Overrides​

Base.toString