Skip to content

GuildTemplateManager

GuildTemplateManager ⇐ Base

Represents a manager for guild templates.

Kind: global class
Extends: Base

new GuildTemplateManager(guildId, client)

Constructs a new instance of the class.

ParamTypeDescription
guildIdstringThe ID of the guild.
clientClientThe client instance.

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

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.

ParamTypeDefaultDescription
templatesstring | ObjectThe template code or an object containing the template code.
[options]objectOptional options for the template.
[options.cache]booleantrueWhether to cache the template or not.
[options.force]booleanfalseWhether to force the template to be retrieved from the cache or not.

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.

ParamTypeDefaultDescription
[options]ObjectOptional parameters for the fetch request.
[options.cache]booleantrueWhether to cache the fetched templates.
[options.force]booleanfalseWhether to force the fetch request even if the templates are already cached.

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.

ParamTypeDescription
optionsObjectThe options for creating the guild template.

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:

  • RangeError If the code is not provided.
ParamTypeDescription
codestring | GuildTemplateThe code or GuildTemplate object of the template to edit.
[options]ObjectThe options for editing the template.

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.
ParamTypeDescription
codestring | GuildTemplateThe code or GuildTemplate object to sync.

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:

  • RangeError If the code is not provided.
ParamTypeDescription
codestring | GuildTemplateThe code or GuildTemplate object of the template to delete.

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.

ParamTypeDescription
oObjectThe payload object to transform.