Skip to content

ChannelManager

ChannelManager ⇐ Base

Represents a Channel Manager that handles operations related to channels.

Kind: global class
Extends: Base

new ChannelManager(client)

Constructs a new instance of the class.

ParamTypeDescription
clientClientThe client object used for communication with the server.

channelManager.cache ⇒

Getter method for the cache property.

Kind: instance property of ChannelManager
Returns: The Collection object representing the cache.

channelManager._add(channels, [guildId], [options]) ⇒ Channel

Adds a channel to the cache and returns the channel object.

Kind: instance method of ChannelManager
Returns: Channel - The added channel object.

ParamTypeDefaultDescription
channelsstring | ChannelThe channel ID or channel object to add.
[guildId]string”this.guildId”The ID of the guild the channel belongs to.
[options]object{cache: true, force: false}Additional options for adding the channel.
[options.cache]booleantrueWhether to cache the channel object.
[options.force]booleanfalseWhether to force fetching the channel from the cache.

channelManager.fetch(channel, [options]) ⇒ Promise.<object>

Fetches a channel from the server based on the provided channel ID or channel object.

Kind: instance method of ChannelManager
Returns: Promise.<object> - - A promise that resolves to the fetched channel object.

ParamTypeDescription
channelstring | objectThe channel ID or channel object to fetch.
[options]objectAdditional options for the fetch operation.
[options.cache]booleanWhether to use the cache for the fetch operation.
[options.force]booleanWhether to force a fresh fetch from the server.

channelManager._fetchId(channel, [cache], [force]) ⇒ Promise.<Channel>

Fetches the ID of a channel from the API.

Kind: instance method of ChannelManager
Returns: Promise.<Channel> - - A promise that resolves to the fetched channel.
Throws:

  • RangeError - If the fetched channel is not a part of the guild.
ParamTypeDefaultDescription
channelstring | ChannelThe channel or channel ID to fetch.
[cache]booleantrueWhether to cache the fetched channel.
[force]booleanfalseWhether to force fetching the channel even if it is already cached.

channelManager.edit(channel, [options]) ⇒ Promise.<Channel>

Edits a channel with the given options.

Kind: instance method of ChannelManager
Returns: Promise.<Channel> - A promise that resolves with the edited channel.

ParamTypeDescription
channelstring | ChannelThe channel to edit. Can be either a channel ID or a Channel object.
[options]ObjectThe options for editing the channel.
[options.reason]stringThe reason for the channel edit.

channelManager.delete(channel, reason) ⇒ Promise.<Channel>

Deletes a channel.

Kind: instance method of ChannelManager
Returns: Promise.<Channel> - - A promise that resolves with the deleted channel.

ParamTypeDescription
channelstring | ChannelThe channel to delete. Can be either a channel ID or a Channel object.
reasonstringThe reason for deleting the channel.

channelManager.createInvite(channel, [options]) ⇒ Promise.<Invite>

Creates an invite for a given channel with optional options.

Kind: instance method of ChannelManager
Returns: Promise.<Invite> - - A promise that resolves with the created invite.

ParamTypeDescription
channelstring | ChannelThe channel or channel ID to create the invite for.
[options]ObjectOptional parameters for creating the invite.
[options.reason]stringThe reason for creating the invite.

channelManager.follow(news, [options]) ⇒ Promise.<string>

Follows a news channel and adds it to the list of followed channels.

Kind: instance method of ChannelManager
Returns: Promise.<string> - - A promise that resolves with the ID of the followed channel.

ParamTypeDescription
newsstring | NewsChannelThe news channel to follow. Can be either a string representing the channel ID or a NewsChannel object.
[options]ObjectAdditional options for following the channel.
[options.reason]stringThe reason for following the channel.
[options.channel]string | NewsChannelThe channel to receive webhook notifications. Can be either a string representing the channel ID or a NewsChannel object.

channelManager.triggerTyping(channel) ⇒ Promise.<void>

Triggers the typing indicator in a given channel.

Kind: instance method of ChannelManager
Returns: Promise.<void> - - A promise that resolves when the typing indicator is triggered.

ParamTypeDescription
channelstring | ChannelThe channel ID or the channel object.

channelManager.clone(channel) ⇒ Promise.<Channel>

Clones a channel by creating a new channel with the same properties and permission overwrites.

Kind: instance method of ChannelManager
Returns: Promise.<Channel> - - A promise that resolves with the cloned channel.
Throws:

  • RangeError - If the channel is not found in the cache.
ParamTypeDescription
channelstring | ChannelThe channel ID or the channel object to clone.

ChannelManager.transformPayload(o, [position]) ⇒ object

Transforms the payload object into the desired format based on the given parameters.

Kind: static method of ChannelManager
Returns: object - - The transformed payload object.

ParamTypeDefaultDescription
oobjectThe payload object to transform.
[position]booleanfalseIndicates whether to include position-related properties in the transformed object.

ChannelManager.transformOverwrites(p) ⇒ Object

Transforms an object of overwrite properties into a standardized format.

Kind: static method of ChannelManager
Returns: Object - - The transformed overwrite object.

ParamTypeDescription
pObjectThe overwrite properties object.
p.idstringThe ID of the overwrite.
p.typestringThe type of the overwrite.
p.allowArray.<string>The permissions to allow for the overwrite.
p.denyArray.<string>The permissions to deny for the overwrite.