ChannelManager
ChannelManager ⇐ Base
Section titled “ChannelManager ⇐ Base”Represents a Channel Manager that handles operations related to channels.
Kind: global class
Extends: Base
- ChannelManager ⇐
Base- new ChannelManager(client)
- instance
- .cache ⇒
- ._add(channels, [guildId], [options]) ⇒
Channel - .fetch(channel, [options]) ⇒
Promise.<object> - ._fetchId(channel, [cache], [force]) ⇒
Promise.<Channel> - .edit(channel, [options]) ⇒
Promise.<Channel> - .delete(channel, reason) ⇒
Promise.<Channel> - .createInvite(channel, [options]) ⇒
Promise.<Invite> - .follow(news, [options]) ⇒
Promise.<string> - .triggerTyping(channel) ⇒
Promise.<void> - .clone(channel) ⇒
Promise.<Channel>
- static
- .transformPayload(o, [position]) ⇒
object - .transformOverwrites(p) ⇒
Object
- .transformPayload(o, [position]) ⇒
new ChannelManager(client)
Section titled “new ChannelManager(client)”Constructs a new instance of the class.
| Param | Type | Description |
|---|---|---|
| client | Client | The client object used for communication with the server. |
channelManager.cache ⇒
Section titled “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
Section titled “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.
| Param | Type | Default | Description |
|---|---|---|---|
| channels | string | Channel | The 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] | boolean | true | Whether to cache the channel object. |
| [options.force] | boolean | false | Whether to force fetching the channel from the cache. |
channelManager.fetch(channel, [options]) ⇒ Promise.<object>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| channel | string | object | The channel ID or channel object to fetch. |
| [options] | object | Additional options for the fetch operation. |
| [options.cache] | boolean | Whether to use the cache for the fetch operation. |
| [options.force] | boolean | Whether to force a fresh fetch from the server. |
channelManager._fetchId(channel, [cache], [force]) ⇒ Promise.<Channel>
Section titled “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.
| Param | Type | Default | Description |
|---|---|---|---|
| channel | string | Channel | The channel or channel ID to fetch. | |
| [cache] | boolean | true | Whether to cache the fetched channel. |
| [force] | boolean | false | Whether to force fetching the channel even if it is already cached. |
channelManager.edit(channel, [options]) ⇒ Promise.<Channel>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| channel | string | Channel | The channel to edit. Can be either a channel ID or a Channel object. |
| [options] | Object | The options for editing the channel. |
| [options.reason] | string | The reason for the channel edit. |
channelManager.delete(channel, reason) ⇒ Promise.<Channel>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| channel | string | Channel | The channel to delete. Can be either a channel ID or a Channel object. |
| reason | string | The reason for deleting the channel. |
channelManager.createInvite(channel, [options]) ⇒ Promise.<Invite>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| channel | string | Channel | The channel or channel ID to create the invite for. |
| [options] | Object | Optional parameters for creating the invite. |
| [options.reason] | string | The reason for creating the invite. |
channelManager.follow(news, [options]) ⇒ Promise.<string>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| news | string | NewsChannel | The news channel to follow. Can be either a string representing the channel ID or a NewsChannel object. |
| [options] | Object | Additional options for following the channel. |
| [options.reason] | string | The reason for following the channel. |
| [options.channel] | string | NewsChannel | The channel to receive webhook notifications. Can be either a string representing the channel ID or a NewsChannel object. |
channelManager.triggerTyping(channel) ⇒ Promise.<void>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| channel | string | Channel | The channel ID or the channel object. |
channelManager.clone(channel) ⇒ Promise.<Channel>
Section titled “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.
| Param | Type | Description |
|---|---|---|
| channel | string | Channel | The channel ID or the channel object to clone. |
ChannelManager.transformPayload(o, [position]) ⇒ object
Section titled “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.
| Param | Type | Default | Description |
|---|---|---|---|
| o | object | The payload object to transform. | |
| [position] | boolean | false | Indicates whether to include position-related properties in the transformed object. |
ChannelManager.transformOverwrites(p) ⇒ Object
Section titled “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.
| Param | Type | Description |
|---|---|---|
| p | Object | The overwrite properties object. |
| p.id | string | The ID of the overwrite. |
| p.type | string | The type of the overwrite. |
| p.allow | Array.<string> | The permissions to allow for the overwrite. |
| p.deny | Array.<string> | The permissions to deny for the overwrite. |