Skip to content

UserManager

UserManager ⇐ Base

Represents a user manager that handles user-related operations.

Kind: global class
Extends: Base

new UserManager(client)

Constructs a new instance of the class.

ParamTypeDescription
clientClientThe client object used for communication with the server.

userManager.cache ⇒

Getter method for the cache property.

Kind: instance property of UserManager
Returns: The Collection object representing the cache.

userManager._add(users, [options]) ⇒ User

Adds a user to the collection.

Kind: instance method of UserManager
Returns: User - The added user object.

ParamTypeDefaultDescription
usersUser | stringThe user object or user ID to add.
[options]ObjectAdditional options for adding the user.
[options.cache]booleantrueWhether to cache the user object.
[options.force]booleanfalseWhether to force fetching the user even if it is already cached.

userManager.fetch(user, [options]) ⇒ Promise.<User>

Fetches user data from the server.

Kind: instance method of UserManager
Returns: Promise.<User> - A promise that resolves to the fetched user data.

ParamTypeDefaultDescription
userstring | UserThe user ID or user object.
[options]ObjectAdditional options for the fetch request.
[options.cache]booleantrueWhether to cache the fetched user data.
[options.force]booleanfalseWhether to force a fresh fetch even if the data is already cached.

userManager.edit(options) ⇒ Promise.<User>

Edits the user’s profile with the provided options.

Kind: instance method of UserManager
Returns: Promise.<User> - A promise that resolves with the updated user object.

ParamTypeDescription
optionsObjectThe options to edit the user’s profile.

userManager.createDM(user) ⇒ Promise.<Channel>

Creates a direct message channel with the specified user.

Kind: instance method of UserManager
Returns: Promise.<Channel> - A promise that resolves with the created direct message channel.
Throws:

  • RangeError If no user is provided.
ParamTypeDescription
userstring | UserThe user to create the direct message channel with.

userManager.send(user, [options]) ⇒ Promise.<Message>

Sends a message to a user through a direct message channel.

Kind: instance method of UserManager
Returns: Promise.<Message> - A promise that resolves to the sent message.

ParamTypeDescription
userUserThe user to send the message to.
[options]ObjectAdditional options for creating the message payload.