Skip to content

Channel

Defined in: packages/structures/src/base.ts:233

Common Discord snowflake-backed structure.

new Channel(data, context?, options?): Channel

Defined in: packages/structures/src/base.ts:253

Creates a channel structure from Discord channel data. options.partial marks a placeholder.

APIChannel

ResourceContext

boolean

Channel

BaseStructure.constructor

optional guildId?: string

Defined in: packages/structures/src/base.ts:236


readonly id: string

Defined in: packages/structures/src/base.ts:12

BaseStructure.id


optional name?: string | null

Defined in: packages/structures/src/base.ts:235


optional nsfw?: boolean

Defined in: packages/structures/src/base.ts:239


optional parentId?: string | null

Defined in: packages/structures/src/base.ts:238


partial: boolean

Defined in: packages/structures/src/base.ts:249

A placeholder built from a message’s channel_id, not from channel data: its type, name, parentId and permissionOverwrites are not the real channel’s, so nothing may decide access from them.


permissionOverwrites: APIOverwrite[]

Defined in: packages/structures/src/base.ts:243

Role and member permission overwrites (empty for DMs and when not provided).


optional position?: number

Defined in: packages/structures/src/base.ts:241


optional rateLimitPerUser?: number

Defined in: packages/structures/src/base.ts:240


optional topic?: string | null

Defined in: packages/structures/src/base.ts:237


type: number

Defined in: packages/structures/src/base.ts:234

get createdAt(): Date

Defined in: packages/structures/src/base.ts:29

Returns the timestamp this snowflake was created at.

Date

BaseStructure.createdAt


get createdTimestamp(): number

Defined in: packages/structures/src/base.ts:25

Milliseconds since the Unix epoch at which this snowflake was created.

number

BaseStructure.createdTimestamp


get kind(): "text" | "dm" | "voice" | "group-dm" | "category" | "announcement" | "thread" | "stage" | "directory" | "forum" | "media" | "unknown"

Defined in: packages/structures/src/base.ts:345

What kind of channel this is: "text", "voice", "thread", "forum"… ("unknown" for a type this version does not know).

"text" | "dm" | "voice" | "group-dm" | "category" | "announcement" | "thread" | "stage" | "directory" | "forum" | "media" | "unknown"

as<K>(…kinds): ChannelOfKind<K>

Defined in: packages/structures/src/base.ts:363

Returns this channel typed as one of kinds.

K extends "text" | "dm" | "voice" | "group-dm" | "category" | "announcement" | "thread" | "stage" | "directory" | "forum" | "media" | "unknown"

…K[]

ChannelOfKind<K>

If it is a different kind.


delete(reason?): Promise<void>

Defined in: packages/structures/src/base.ts:333

Deletes this channel.

string

Audit-log reason.

Promise<void>

A promise fulfilled when Discord confirms deletion.

If the channel is not attached to a client.


edit(options): Promise<Channel>

Defined in: packages/structures/src/base.ts:288

Edits this channel.

Record<string, unknown>

Channel fields to change.

Promise<Channel>

The updated channel.

If the channel is not attached to a client.


editName(name): Promise<Channel>

Defined in: packages/structures/src/base.ts:295

Changes only this channel’s name.

string

New channel name.

Promise<Channel>

The updated channel.

If the name is empty.

If the channel is not attached to a client.


editParent(parentId): Promise<Channel>

Defined in: packages/structures/src/base.ts:328

string | null

Promise<Channel>


editPermissionOverwrite(targetId, changes, options?): Promise<void>

Defined in: packages/structures/src/base.ts:313

Changes some permissions of one overwrite and keeps the rest: true allows, false denies, null resets to inherited.

string

Role or member ID.

PermissionOverwriteChanges

Permissions to change.

type (0 role, 1 member) when the overwrite does not exist yet; audit-log reason.

string

0 | 1

Promise<void>

channel.editPermissionOverwrite(userId, { ViewChannel: true, SendMessages: false }, { type: 1 })

editTopic(topic): Promise<Channel>

Defined in: packages/structures/src/base.ts:301

Changes only this channel’s topic.

string | null

New topic, or null to clear it.

Promise<Channel>

The updated channel.

If the channel is not attached to a client.


is<K>(…kinds): this is ChannelOfKind<K>

Defined in: packages/structures/src/base.ts:353

Whether this channel is one of kinds, narrowing its type to match.

K extends "text" | "dm" | "voice" | "group-dm" | "category" | "announcement" | "thread" | "stage" | "directory" | "forum" | "media" | "unknown"

…K[]

this is ChannelOfKind<K>

if (channel.is("text", "announcement")) await channel.send({ content: "hi" });

isDMBased(): boolean

Defined in: packages/structures/src/base.ts:389

Whether this is a direct-message channel (DM or group DM).

boolean


isTextBased(): boolean

Defined in: packages/structures/src/base.ts:379

Whether messages can be sent in this channel (text, DM, announcement, voice, stage, threads).

boolean


isThread(): boolean

Defined in: packages/structures/src/base.ts:374

Whether this is a thread (announcement, public or private).

boolean


isVoiceBased(): boolean

Defined in: packages/structures/src/base.ts:384

Whether this is a voice or stage channel.

boolean


send(options): Promise<Message>

Defined in: packages/structures/src/base.ts:279

Sends a message to this channel.

MessageCreateOptions

Message payload.

Promise<Message>

The created message.

If the channel is not attached to a client.


toString(): string

Defined in: packages/structures/src/base.ts:394

Returns the Discord channel mention string. Used automatically in template literals.

string

BaseStructure.toString


update(options): Promise<Channel>

Defined in: packages/structures/src/base.ts:340

Updates this channel using the same resource operation as edit.

Record<string, unknown>

Channel fields to change.

Promise<Channel>

The updated channel.

If the channel is not attached to a client.