Skip to content

GuildManager

GuildManager ⇐ Base

Represents a manager for guild-related operations.

Kind: global class
Extends: Base

new GuildManager(client, websocket)

Constructs a new instance of the class.

ParamTypeDescription
clientClientThe client object.
websocketWebSocketThe 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.

ParamTypeDefaultDescription
guildsstring | GuildThe guild ID or the guild object to add.
[options]objectAdditional options for adding the guild.
[options.cache]booleantrueWhether to cache the guild object.
[options.force]booleanfalseWhether 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.

ParamTypeDescription
optionsObjectThe options for creating the guild.

guildManager.fetch(guild, options) ⇒ Promise.<Cache>

Fetches guild information from the Discord API.

Kind: instance method of GuildManager

ParamTypeDescription
guildstring | objectThe guild ID or guild object to fetch.
optionsobjectAdditional options for the fetch request.
options.cachebooleanWhether to cache the fetched guild information.
options.forcebooleanWhether to force fetch the guild information even if it is already cached.
options.beforestringThe ID of the guild to fetch guilds before.
options.afterstringThe ID of the guild to fetch guilds after.
options.limitnumberThe 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.

ParamTypeDescription
guildstring | GuildThe guild or guild ID to fetch the ID for.
[options]ObjectAdditional options for the fetch.
[options.cache]booleanWhether to cache the fetched ID.
[options.force]booleanWhether to force the fetch even if the ID is already cached.
[options.withCounts]booleanWhether 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.

ParamTypeDescription
guildsstring | GuildThe ID or the Guild object of the guild to edit.
[options]ObjectThe options to edit the guild with.
[options.reason]stringThe 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.

ParamTypeDescription
guildstring | GuildThe 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.

ParamTypeDescription
guildstring | GuildThe 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.
ParamTypeDescription
guildstring | GuildThe guild or guild ID to modify.
[options]ObjectAdditional options for the modification.
[options.reason]stringThe reason for the modification.
[options.mfaLevel]string | numberThe 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.

ParamTypeDescription
payloadObjectThe 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.

ParamTypeDescription
oObjectThe options object.
[o.before]stringThe “before” property of the options object.
[o.after]stringThe “after” property of the options object.
[o.limit]numberThe “limit” property of the options object.