GuildManager
GuildManager ⇐ Base
Represents a manager for guild-related operations.
Kind: global class
Extends: Base
- GuildManager ⇐
Base
- new GuildManager(client, websocket)
- instance
- .cache ⇒
- ._add(guilds, [options]) ⇒
Guild
|null
- .create(options) ⇒
Promise
- .fetch(guild, options) ⇒
Promise.<Cache>
- ._fetchId(guild, [options]) ⇒
Promise.<string>
- .edit(guilds, [options]) ⇒
Promise.<Guild>
- .delete(guild) ⇒
Promise.<Guild>
- .fetchPreview(guild) ⇒
Promise.<GuildPreview>
- .modifyMFALevel(guild, [options]) ⇒
Promise.<Guild>
- static
- .transformPayload(payload) ⇒
Object
- .transformOptions(o) ⇒
Object
- .transformPayload(payload) ⇒
new GuildManager(client, websocket)
Constructs a new instance of the class.
Param | Type | Description |
---|---|---|
client | Client | The client object. |
websocket | WebSocket | The WebSocket object. |
guildManager.cache ⇒
Getter method for the cache property.
Kind: instance property of GuildManager
Returns: The Collection object representing the cache.
guildManager._add(guilds, [options]) ⇒ Guild
| null
Adds a guild to the cache and returns the guild object.
Kind: instance method of GuildManager
Returns: Guild
| null
- The guild object that was added to the cache, or null if the guild is not provided.
Param | Type | Default | Description |
---|---|---|---|
guilds | string | Guild | The guild ID or the guild object to add. | |
[options] | object | Additional options for adding the guild. | |
[options.cache] | boolean | true | Whether to cache the guild object. |
[options.force] | boolean | false | Whether to force adding the guild even if it already exists in the cache. |
guildManager.create(options) ⇒ Promise
Creates a new guild with the given options.
Kind: instance method of GuildManager
Returns: Promise
- A promise that resolves with the created guild.
Param | Type | Description |
---|---|---|
options | Object | The options for creating the guild. |
guildManager.fetch(guild, options) ⇒ Promise.<Cache>
Fetches guild information from the Discord API.
Kind: instance method of GuildManager
Param | Type | Description |
---|---|---|
guild | string | object | The guild ID or guild object to fetch. |
options | object | Additional options for the fetch request. |
options.cache | boolean | Whether to cache the fetched guild information. |
options.force | boolean | Whether to force fetch the guild information even if it is already cached. |
options.before | string | The ID of the guild to fetch guilds before. |
options.after | string | The ID of the guild to fetch guilds after. |
options.limit | number | The maximum number of guilds to fetch. |
guildManager._fetchId(guild, [options]) ⇒ Promise.<string>
Fetches the ID of a guild asynchronously.
Kind: instance method of GuildManager
Returns: Promise.<string>
- - A promise that resolves with the fetched guild ID.
Param | Type | Description |
---|---|---|
guild | string | Guild | The guild or guild ID to fetch the ID for. |
[options] | Object | Additional options for the fetch. |
[options.cache] | boolean | Whether to cache the fetched ID. |
[options.force] | boolean | Whether to force the fetch even if the ID is already cached. |
[options.withCounts] | boolean | Whether to include counts in the fetch query. |
guildManager.edit(guilds, [options]) ⇒ Promise.<Guild>
Edits a guild with the given options.
Kind: instance method of GuildManager
Returns: Promise.<Guild>
- A promise that resolves with the edited guild.
Param | Type | Description |
---|---|---|
guilds | string | Guild | The ID or the Guild object of the guild to edit. |
[options] | Object | The options to edit the guild with. |
[options.reason] | string | The reason for the edit. |
guildManager.delete(guild) ⇒ Promise.<Guild>
Deletes a guild from the server.
Kind: instance method of GuildManager
Returns: Promise.<Guild>
- - The deleted guild.
Param | Type | Description |
---|---|---|
guild | string | Guild | The guild to delete. Can be either a guild ID or a Guild object. |
guildManager.fetchPreview(guild) ⇒ Promise.<GuildPreview>
Fetches the preview information for a guild.
Kind: instance method of GuildManager
Returns: Promise.<GuildPreview>
- - A promise that resolves to a GuildPreview object.
Param | Type | Description |
---|---|---|
guild | string | Guild | The guild ID or guild object. |
guildManager.modifyMFALevel(guild, [options]) ⇒ Promise.<Guild>
Modifies the MFA (Multi-Factor Authentication) level for a guild.
Kind: instance method of GuildManager
Returns: Promise.<Guild>
- A promise that resolves with the modified guild.
Throws:
RangeError
If no guild ID is specified.
Param | Type | Description |
---|---|---|
guild | string | Guild | The guild or guild ID to modify. |
[options] | Object | Additional options for the modification. |
[options.reason] | string | The reason for the modification. |
[options.mfaLevel] | string | number | The new MFA level to set for the guild. |
GuildManager.transformPayload(payload) ⇒ Object
Transforms the given payload object into a new format.
Kind: static method of GuildManager
Returns: Object
- - The transformed payload object.
Param | Type | Description |
---|---|---|
payload | Object | The payload object to transform. |
GuildManager.transformOptions(o) ⇒ Object
Transforms the options object by extracting the “before” and “after” properties and setting them to their corresponding IDs if they are strings, or undefined if they are not provided. The “limit” property is set to 200 if it is not provided.
Kind: static method of GuildManager
Returns: Object
- - The transformed options object.
Param | Type | Description |
---|---|---|
o | Object | The options object. |
[o.before] | string | The “before” property of the options object. |
[o.after] | string | The “after” property of the options object. |
[o.limit] | number | The “limit” property of the options object. |