Skip to content

CategoryChannel

classe · Source

Represents a guild category channel on Discord.

Extends: GuildChannel

Properties

parentId

parentId: null

The id of the parent of this channel. Source

parent

readonly

parent: null

The parent of this channel. Source

children

readonly

children: Collection<Snowflake, GuildChannel>

Channels that are a part of this category Source

guild

guild: Guild

The guild the channel is in Source

guildId

guildId: Snowflake

The id of the guild the channel is in Source

permissionOverwrites

permissionOverwrites: PermissionOverwriteManager

A manager of permission overwrites that belong to this channel Source

name

name: string

The name of the guild channel Source

rawPosition

rawPosition: number

The raw position of the channel from Discord Source

permissionsLocked

readonly · nullable

permissionsLocked: boolean

If the permissionOverwrites match the parent channel, null if no parent Source

position

readonly

position: number

The position of the channel Source

members

readonly

members: Collection<Snowflake, GuildMember>

A collection of cached members of this channel, mapped by their ids. Members that can view this channel, if the channel is text-based. Members in the channel, if the channel is voice-based. Source

deletable

readonly

deletable: boolean

Whether the channel is deletable by the client user Source

manageable

readonly

manageable: boolean

Whether the channel is manageable by the client user Source

viewable

readonly

viewable: boolean

Whether the channel is viewable by the client user Source

type

type: ChannelType

The type of the channel Source

id

id: Snowflake

The channel's id Source

flags

nullable

flags: Readonly<ChannelFlags>

The flags that are applied to the channel. Source

createdTimestamp

readonly

createdTimestamp: number

The timestamp the channel was created at Source

createdAt

readonly

createdAt: Date

The time the channel was created at Source

deleted

deprecated

deleted: boolean

Whether or not the structure has been deleted Source

partial

readonly

partial: boolean

Whether this Channel is a partial This is always false outside of DM channels. Source

client

readonly

client: Client

The client that instantiated this Source

Methods

setParent

setParent(channel: CategoryChannelResolvable, options?: SetParentOptions): Promise<GuildChannel>

Sets the category parent of this channel. It is not possible to set the parent of a CategoryChannel. Parameters

NameTypeDescription
channelCategoryChannelResolvableThe channel to set as parent
options?SetParentOptionsThe options for setting the parent Default: {}.

Returns: Promise<GuildChannel>Source

createChannel

createChannel(name: string, options: CategoryCreateChannelOptions): Promise<GuildChannel>

Creates a new channel within this category. You cannot create a channel of type GUILD_CATEGORY inside a CategoryChannel. Parameters

NameTypeDescription
namestringThe name of the new channel
optionsCategoryCreateChannelOptionsOptions for creating the new channel

Returns: Promise<GuildChannel>Source

permissionsFor

permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable, checkAdmin?: boolean): Readonly<Permissions>

Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
memberOrRoleGuildMemberResolvable | RoleResolvableThe member or role to obtain the overall permissions for
checkAdmin?booleanWhether having ADMINISTRATOR will return all permissions Default: true.

Returns: Readonly<Permissions>Source

memberPermissions

private

memberPermissions(member: GuildMember, checkAdmin: boolean): Readonly<Permissions>

Gets the overall set of permissions for a member in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
memberGuildMemberThe member to obtain the overall permissions for
checkAdminbooleanWhether having ADMINISTRATOR will return all permissions Default: true.

Returns: Readonly<Permissions>Source

rolePermissions

private

rolePermissions(role: Role, checkAdmin: boolean): Readonly<Permissions>

Gets the overall set of permissions for a role in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
roleRoleThe role to obtain the overall permissions for
checkAdminbooleanWhether having ADMINISTRATOR will return all permissions

Returns: Readonly<Permissions>Source

lockPermissions

async

async lockPermissions(): Promise<GuildChannel>

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

edit

edit(data: ChannelData, reason?: string): Promise<GuildChannel>

Edits the channel. Parameters

NameTypeDescription
dataChannelDataThe new data for the channel
reason?stringReason for editing this channel

Returns: Promise<GuildChannel>

js
// Edit a channel
channel.edit({ name: 'new-channel' })
  .then(console.log)
  .catch(console.error);

Source

setName

setName(name: string, reason?: string): Promise<GuildChannel>

Sets a new name for the guild channel. Parameters

NameTypeDescription
namestringThe new name for the guild channel
reason?stringReason for changing the guild channel's name

Returns: Promise<GuildChannel>

js
// Set a new channel name
channel.setName('not_general')
  .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
  .catch(console.error);

Source

setPosition

setPosition(position: number, options?: SetChannelPositionOptions): Promise<GuildChannel>

Sets a new position for the guild channel. Parameters

NameTypeDescription
positionnumberThe new position for the guild channel
options?SetChannelPositionOptionsOptions for setting position

Returns: Promise<GuildChannel>

js
// Set a new channel position
channel.setPosition(2)
  .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
  .catch(console.error);

Source

clone

clone(options?: GuildChannelCloneOptions): Promise<GuildChannel>

Clones this channel. Parameters

NameTypeDescription
options?GuildChannelCloneOptionsThe options for cloning this channel

Returns: Promise<GuildChannel>Source

equals

equals(channel: GuildChannel): 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

NameTypeDescription
channelGuildChannelChannel to compare with

Returns: booleanSource

delete

async

async delete(reason?: string): Promise<GuildChannel>

Deletes this channel. Parameters

NameTypeDescription
reason?stringReason for deleting this channel

Returns: Promise<GuildChannel>

js
// Delete the channel
channel.delete('making room for new channels')
  .then(console.log)
  .catch(console.error);

Source

toString

toString(): string

When concatenated with a string, this automatically returns the channel's mention instead of the Channel object. Returns: string

js
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);

Source

fetch

fetch(force?: boolean): Promise<Channel>

Fetches this channel. Parameters

NameTypeDescription
force?booleanWhether to skip the cache check and request the API Default: true.

Returns: Promise<Channel>Source

isText

isText(): boolean

Indicates whether this channel is text-based. Returns: booleanSource

isVoice

isVoice(): boolean

Indicates whether this channel is voice-based. Returns: booleanSource

isThread

isThread(): boolean

Indicates whether this channel is a ThreadChannel. Returns: booleanSource

isThreadOnly

isThreadOnly(): boolean

Indicates whether this channel is ThreadOnlyChannel. Returns: booleanSource

isDirectory

isDirectory(): boolean

Indicates whether this channel is a DirectoryChannelReturns: booleanSource

Unofficial software. Not affiliated with or supported by Discord.