Class: CategoryChannel

CategoryChannel

Represents a guild category channel on Discord.

Constructor

new CategoryChannel()

Source:

Extends

Members

(readonly) children :Collection.<Snowflake, GuildChannel>

Channels that are a part of this category
Type:
Source:

(readonly) client :Client

The client that instantiated this
Type:
Inherited From:
Source:

(readonly) createdAt :Date

The time the channel was created at
Type:
  • Date
Inherited From:
Source:

(readonly) createdTimestamp :number

The timestamp the channel was created at
Type:
  • number
Inherited From:
Source:

(readonly) deletable :boolean

Whether the channel is deletable by the client user
Type:
  • boolean
Inherited From:
Source:

deleted :boolean

Whether the channel has been deleted
Type:
  • boolean
Inherited From:
Source:

guild :Guild

The guild the channel is in
Type:
Inherited From:
Source:

id :Snowflake

The unique ID of the channel
Type:
Inherited From:
Source:

(readonly) manageable :boolean

Whether the channel is manageable by the client user
Type:
  • boolean
Inherited From:
Source:

(readonly) members :Collection.<Snowflake, GuildMember>

A collection of members that can see this channel, mapped by their ID
Type:
Inherited From:
Source:

name :string

The name of the guild channel
Type:
  • string
Inherited From:
Source:

(readonly, nullable) parent :CategoryChannel

The category parent of this channel
Type:
Inherited From:
Source:

(nullable) parentID :Snowflake

The ID of the category parent of this channel
Type:
Inherited From:
Source:

permissionOverwrites :Collection.<Snowflake, PermissionOverwrites>

A map of permission overwrites in this channel for roles and users
Type:
Inherited From:
Source:

(readonly, nullable) permissionsLocked :boolean

If the permissionOverwrites match the parent channel, null if no parent
Type:
  • boolean
Inherited From:
Source:

(readonly) position :number

The position of the channel
Type:
  • number
Inherited From:
Source:

rawPosition :number

The raw position of the channel from discord
Type:
  • number
Inherited From:
Source:

type :string

The type of the channel, either: * `dm` - a DM channel * `text` - a guild text channel * `voice` - a guild voice channel * `category` - a guild category channel * `news` - a guild news channel * `store` - a guild store channel * `unknown` - a generic channel of unknown type, could be Channel or GuildChannel
Type:
  • string
Inherited From:
Source:

(readonly) viewable :boolean

Whether the channel is viewable by the client user
Type:
  • boolean
Inherited From:
Source:

Methods

clone(optionsopt) → {Promise.<GuildChannel>}

Clones this channel.
Parameters:
Name Type Attributes Description
options Object <optional>
The options
Properties
Name Type Attributes Default Description
name string <optional>
this.name Name of the new channel
permissionOverwrites Array.<OverwriteResolvable> | Collection.<Snowflake, OverwriteResolvable> <optional>
this.permissionOverwrites Permission overwrites of the new channel
type string <optional>
this.type Type of the new channel
topic string <optional>
this.topic Topic of the new channel (only text)
nsfw boolean <optional>
this.nsfw Whether the new channel is nsfw (only text)
bitrate number <optional>
this.bitrate Bitrate of the new channel in bits (only voice)
userLimit number <optional>
this.userLimit Maximum amount of users allowed in the new channel (only voice)
rateLimitPerUser number <optional>
this.rateLimitPerUser Ratelimit per user for the new channel (only text)
parent ChannelResolvable <optional>
this.parent Parent of the new channel
reason string <optional>
Reason for cloning this channel
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>

createInvite(optionsopt) → {Promise.<Invite>}

Creates an invite to this guild channel.
Parameters:
Name Type Attributes Default Description
options Object <optional>
{} Options for the invite
Properties
Name Type Attributes Default Description
temporary boolean <optional>
false Whether members that joined via the invite should be automatically kicked after 24 hours if they have not yet received a role
maxAge number <optional>
86400 How long the invite should last (in seconds, 0 for forever)
maxUses number <optional>
0 Maximum number of uses
unique boolean <optional>
false Create a unique invite, or use an existing one with similar settings
reason string <optional>
Reason for creating this
Inherited From:
Source:
Returns:
Type
Promise.<Invite>
Example
// Create an invite to a channel
channel.createInvite()
  .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
  .catch(console.error);

createOverwrite(userOrRole, options, reasonopt) → {Promise.<GuildChannel>}

Overwrites the permissions for a user or role in this channel. (replaces if existent)
Parameters:
Name Type Attributes Description
userOrRole RoleResolvable | UserResolvable The user or role to update
options PermissionOverwriteOptions The options for the update
reason string <optional>
Reason for creating/editing this overwrite
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Create or Replace permissions overwrites for a message author
message.channel.createOverwrite(message.author, {
  SEND_MESSAGES: false
})
  .then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
  .catch(console.error);

delete(reasonopt) → {Promise.<GuildChannel>}

Deletes this channel.
Parameters:
Name Type Attributes Description
reason string <optional>
Reason for deleting this channel
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Delete the channel
channel.delete('making room for new channels')
  .then(console.log)
  .catch(console.error);

edit(data, reasonopt) → {Promise.<GuildChannel>}

Edits the channel.
Parameters:
Name Type Attributes Description
data ChannelData The new data for the channel
reason string <optional>
Reason for editing this channel
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Edit a channel
channel.edit({ name: 'new-channel' })
  .then(console.log)
  .catch(console.error);

equals(channel) → {boolean}

Checks if this channel has the same type, topic, position, name, overwrites and ID as another channel. In most cases, a simple `channel.id === channel2.id` will do, and is much faster too.
Parameters:
Name Type Description
channel GuildChannel Channel to compare with
Inherited From:
Source:
Returns:
Type
boolean

fetch(forceopt) → {Promise.<Channel>}

Fetches this channel.
Parameters:
Name Type Attributes Default Description
force boolean <optional>
false Whether to skip the cache check and request the API
Inherited From:
Source:
Returns:
Type
Promise.<Channel>

fetchInvites() → {Promise.<Collection.<string, Invite>>}

Fetches a collection of invites to this guild channel. Resolves with a collection mapping invites by their codes.
Inherited From:
Source:
Returns:
Type
Promise.<Collection.<string, Invite>>

isText() → {boolean}

Indicates whether this channel is text-based.
Inherited From:
Source:
Returns:
Type
boolean

lockPermissions() → {Promise.<GuildChannel>}

Locks in the permission overwrites from the parent channel.
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>

(private) memberPermissions(member) → {Readonly.<Permissions>}

Gets the overall set of permissions for a member in this channel, taking into account channel overwrites.
Parameters:
Name Type Description
member GuildMember The member to obtain the overall permissions for
Inherited From:
Source:
Returns:
Type
Readonly.<Permissions>

overwritePermissions(overwrites, reasonopt) → {Promise.<GuildChannel>}

Replaces the permission overwrites in this channel.
Parameters:
Name Type Attributes Description
overwrites Array.<OverwriteResolvable> | Collection.<Snowflake, OverwriteResolvable> Permission overwrites the channel gets updated with
reason string <optional>
Reason for updating the channel overwrites
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
channel.overwritePermissions([
  {
     id: message.author.id,
     deny: ['VIEW_CHANNEL'],
  },
], 'Needed to change permissions');

permissionsFor(memberOrRole) → {Readonly.<Permissions>}

Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites.
Parameters:
Name Type Description
memberOrRole GuildMemberResolvable | RoleResolvable The member or role to obtain the overall permissions for
Inherited From:
Source:
Returns:
Type
Readonly.<Permissions>

(private) rolePermissions(role) → {Readonly.<Permissions>}

Gets the overall set of permissions for a role in this channel, taking into account channel overwrites.
Parameters:
Name Type Description
role Role The role to obtain the overall permissions for
Inherited From:
Source:
Returns:
Type
Readonly.<Permissions>

setName(name, reasonopt) → {Promise.<GuildChannel>}

Sets a new name for the guild channel.
Parameters:
Name Type Attributes Description
name string The new name for the guild channel
reason string <optional>
Reason for changing the guild channel's name
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Set a new channel name
channel.setName('not_general')
  .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
  .catch(console.error);

setParent(channel, optionsopt) → {Promise.<GuildChannel>}

Sets the category parent of this channel.
Parameters:
Name Type Attributes Default Description
channel CategoryChannel | Snowflake Parent channel
options Object <optional>
{} Options to pass
Properties
Name Type Attributes Default Description
lockPermissions boolean <optional>
true Lock the permissions to what the parent's permissions are
reason string <optional>
Reason for modifying the parent of this channel
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Add a parent to a channel
message.channel.setParent('355908108431917066', { lockPermissions: false })
  .then(channel => console.log(`New parent of ${message.channel.name}: ${channel.name}`))
  .catch(console.error);

setPosition(position, optionsopt) → {Promise.<GuildChannel>}

Sets a new position for the guild channel.
Parameters:
Name Type Attributes Description
position number The new position for the guild channel
options Object <optional>
Options for setting position
Properties
Name Type Attributes Default Description
relative boolean <optional>
false Change the position relative to its current value
reason string <optional>
Reason for changing the position
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Set a new channel position
channel.setPosition(2)
  .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
  .catch(console.error);

setTopic(topic, reasonopt) → {Promise.<GuildChannel>}

Sets a new topic for the guild channel.
Parameters:
Name Type Attributes Description
topic string The new topic for the guild channel
reason string <optional>
Reason for changing the guild channel's topic
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Set a new channel topic
channel.setTopic('needs more rate limiting')
  .then(newChannel => console.log(`Channel's new topic is ${newChannel.topic}`))
  .catch(console.error);

toString() → {string}

When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
Inherited From:
Source:
Returns:
Type
string
Example
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);

updateOverwrite(userOrRole, options, reasonopt) → {Promise.<GuildChannel>}

Updates Overwrites for a user or role in this channel. (creates if non-existent)
Parameters:
Name Type Attributes Description
userOrRole RoleResolvable | UserResolvable The user or role to update
options PermissionOverwriteOptions The options for the update
reason string <optional>
Reason for creating/editing this overwrite
Inherited From:
Source:
Returns:
Type
Promise.<GuildChannel>
Example
// Update or Create permission overwrites for a message author
message.channel.updateOverwrite(message.author, {
  SEND_MESSAGES: false
})
  .then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
  .catch(console.error);