UserManager
UserManager ⇐ Base
Represents a user manager that handles user-related operations.
Kind: global class
Extends: Base
- UserManager ⇐
Base
- new UserManager(client)
- .cache ⇒
- ._add(users, [options]) ⇒
User
- .fetch(user, [options]) ⇒
Promise.<User>
- .edit(options) ⇒
Promise.<User>
- .createDM(user) ⇒
Promise.<Channel>
- .send(user, [options]) ⇒
Promise.<Message>
new UserManager(client)
Constructs a new instance of the class.
Param | Type | Description |
---|---|---|
client | Client | The 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.
Param | Type | Default | Description |
---|---|---|---|
users | User | string | The user object or user ID to add. | |
[options] | Object | Additional options for adding the user. | |
[options.cache] | boolean | true | Whether to cache the user object. |
[options.force] | boolean | false | Whether 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.
Param | Type | Default | Description |
---|---|---|---|
user | string | User | The user ID or user object. | |
[options] | Object | Additional options for the fetch request. | |
[options.cache] | boolean | true | Whether to cache the fetched user data. |
[options.force] | boolean | false | Whether 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.
Param | Type | Description |
---|---|---|
options | Object | The 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.
Param | Type | Description |
---|---|---|
user | string | User | The 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.
Param | Type | Description |
---|---|---|
user | User | The user to send the message to. |
[options] | Object | Additional options for creating the message payload. |