GuildTemplateManager
GuildTemplateManager ⇐ Base
Section titled “GuildTemplateManager ⇐ Base”Represents a manager for guild templates.
Kind: global class
Extends: Base
- GuildTemplateManager ⇐
Base- new GuildTemplateManager(guildId, client)
- instance
- .cache ⇒
- ._add(templates, [options]) ⇒
GuildTemplate|null - .fetch([options]) ⇒
Promise.<Cache> - .create(options) ⇒
Promise.<Object> - .edit(code, [options]) ⇒
Promise.<GuildTemplate> - .sync(code) ⇒
Promise.<GuildTemplate> - .delete(code) ⇒
Promise.<GuildTemplate>
- static
- .transformPayload(o) ⇒
Object
- .transformPayload(o) ⇒
new GuildTemplateManager(guildId, client)
Section titled “new GuildTemplateManager(guildId, client)”Constructs a new instance of the class.
| Param | Type | Description |
|---|---|---|
| guildId | string | The ID of the guild. |
| client | Client | The client instance. |
guildTemplateManager.cache ⇒
Section titled “guildTemplateManager.cache ⇒”Getter method for the cache property.
Kind: instance property of GuildTemplateManager
Returns: The Collection object representing the cache.
guildTemplateManager._add(templates, [options]) ⇒ GuildTemplate | null
Section titled “guildTemplateManager._add(templates, [options]) ⇒ GuildTemplate | null”Adds a template to the cache and returns the template object.
Kind: instance method of GuildTemplateManager
Returns: GuildTemplate | null - The template object if it exists, otherwise null.
| Param | Type | Default | Description |
|---|---|---|---|
| templates | string | Object | The template code or an object containing the template code. | |
| [options] | object | Optional options for the template. | |
| [options.cache] | boolean | true | Whether to cache the template or not. |
| [options.force] | boolean | false | Whether to force the template to be retrieved from the cache or not. |
guildTemplateManager.fetch([options]) ⇒ Promise.<Cache>
Section titled “guildTemplateManager.fetch([options]) ⇒ Promise.<Cache>”Fetches templates from the server.
Kind: instance method of GuildTemplateManager
Returns: Promise.<Cache> - - A promise that resolves to a cache object containing the fetched templates.
| Param | Type | Default | Description |
|---|---|---|---|
| [options] | Object | Optional parameters for the fetch request. | |
| [options.cache] | boolean | true | Whether to cache the fetched templates. |
| [options.force] | boolean | false | Whether to force the fetch request even if the templates are already cached. |
guildTemplateManager.create(options) ⇒ Promise.<Object>
Section titled “guildTemplateManager.create(options) ⇒ Promise.<Object>”Creates a guild template with the given options.
Kind: instance method of GuildTemplateManager
Returns: Promise.<Object> - A promise that resolves to the created guild template.
| Param | Type | Description |
|---|---|---|
| options | Object | The options for creating the guild template. |
guildTemplateManager.edit(code, [options]) ⇒ Promise.<GuildTemplate>
Section titled “guildTemplateManager.edit(code, [options]) ⇒ Promise.<GuildTemplate>”Edits a guild template with the given code and options.
Kind: instance method of GuildTemplateManager
Returns: Promise.<GuildTemplate> - A promise that resolves with the edited GuildTemplate object.
Throws:
RangeErrorIf the code is not provided.
| Param | Type | Description |
|---|---|---|
| code | string | GuildTemplate | The code or GuildTemplate object of the template to edit. |
| [options] | Object | The options for editing the template. |
guildTemplateManager.sync(code) ⇒ Promise.<GuildTemplate>
Section titled “guildTemplateManager.sync(code) ⇒ Promise.<GuildTemplate>”Synchronizes a guild template with the provided code.
Kind: instance method of GuildTemplateManager
Returns: Promise.<GuildTemplate> - - A promise that resolves with the synchronized GuildTemplate.
Throws:
RangeError- If the code is not provided.
| Param | Type | Description |
|---|---|---|
| code | string | GuildTemplate | The code or GuildTemplate object to sync. |
guildTemplateManager.delete(code) ⇒ Promise.<GuildTemplate>
Section titled “guildTemplateManager.delete(code) ⇒ Promise.<GuildTemplate>”Deletes a guild template.
Kind: instance method of GuildTemplateManager
Returns: Promise.<GuildTemplate> - A promise that resolves with the deleted template.
Throws:
RangeErrorIf the code is not provided.
| Param | Type | Description |
|---|---|---|
| code | string | GuildTemplate | The code or GuildTemplate object of the template to delete. |
GuildTemplateManager.transformPayload(o) ⇒ Object
Section titled “GuildTemplateManager.transformPayload(o) ⇒ Object”Transforms the given payload object by extracting the “name” and “description” properties. If these properties are not present in the object, they will be set to undefined in the returned object.
Kind: static method of GuildTemplateManager
Returns: Object - - The transformed object with “name” and “description” properties.
| Param | Type | Description |
|---|---|---|
| o | Object | The payload object to transform. |