Skip to main content
A channel is where things happen in Discord: a text channel, a voice channel, a category, a forum, a thread or a private conversation. Each kind has its own class, and they all share what Channel has. You get one from guild.channels, message.channel, the channel of a command, or a channel option.
How to send, edit and read messages is in Sending messages. This page lists what the channels have; each kind has its own page below.

Which kind of channel

A channel you get from guild.channels or message.channel can be of any kind. Ask it before using what only one kind has: inside the if, your editor knows the kind. type says the same thing as a value of ChannelType: A kind Discord added after this version is still usable: as a GuildChannel when it is in a server, as a Channel otherwise.

TextChannel

A text or announcement channel of a server.

VoiceChannel

A voice or stage channel: people talk in it, and can write too.

CategoryChannel

A category: it groups channels.

ForumChannel

A forum or media channel: it only contains posts, which are threads.

ThreadChannel

A thread, or a post of a forum.

DMChannel

A private conversation between the bot and a user.

Channel

A channel of any kind. Use the is...() methods to know which kind it is and get the properties and actions of that kind. Every class of this section has what is listed here.

Properties

Snowflake
The unique id Discord gave it.
Date
When it was created: a Discord id contains its creation date.
ChannelType
The kind of channel, as a value of ChannelType.
Snowflake | null
The id of the server of the channel; null for a private one.
Guild | null
The server of the channel; null for a private one.

Helpers

These read what the bot already knows: they never send a request.

isTextBased()

Whether messages can be sent in it.

isGuildChannel()

Whether it belongs to a server and is not a thread.

isText()

A text or announcement channel of a server.

isVoice()

A voice or stage channel.

isCategory()

A category, which groups channels.

isForum()

A forum or media channel, made of posts.

isThread()

A thread, or a post of a forum.

isDM()

A private conversation.

toString()

<#id>: links the channel when put in a message.

toJSON()

The data of Discord as a plain object, with camelCase names.

Reading from Discord

fetch()

Asks Discord for the latest data of the channel.

Actions

delete()

Deletes the channel (closes it, for a private conversation). Discord documentation

GuildChannel

A channel of a server (not a thread). TextChannel, VoiceChannel, CategoryChannel and ForumChannel have everything listed here, plus what Channel has.

Properties

Snowflake
The id of the server of the channel.
Guild
The server of the channel.
string
The name of the channel.
number
Where the channel is in the list.
Snowflake | null
The id of the category of the channel, when it is in one.
CategoryChannel | null
The category of the channel, when it is in one and it is known.
boolean
Whether the channel is age-restricted.
PermissionOverwrite[]
What roles and members are allowed or denied in this channel. Each entry is a PermissionOverwrite.

Helpers

permissionsFor()

What a member can do in this channel: their permissions in the server, changed by the overwrites of the channel. Discord documentation

Reading from Discord

fetchInvites()

The invites that lead to this channel. Discord documentation

fetchWebhooks()

The webhooks that post in this channel. Discord documentation

Actions

edit()

Changes the channel. The options are a GuildChannelEditOptions. Discord documentation

setPermissions()

Allows or denies permissions to a role or a member in this channel. Permissions that are in neither list follow the server. Discord documentation

deletePermissions()

Removes what was set for a role or a member in this channel. Discord documentation

createInvite()

Creates an invite to this channel. The options are an InviteCreateOptions. Discord documentation

createWebhook()

Creates a webhook that posts in this channel: see Webhook.
string
required
The name of the webhook (1 to 80 characters).
string | null
The image of the default avatar of the webhook, as a data URI (data:image/png;base64,...).
Discord documentation

Channels with messages

TextChannel, VoiceChannel, ThreadChannel and DMChannel can all send and read messages: they share the properties and methods of this section. Together they are the TextBasedChannel type.

Properties

ReadonlyMap<Snowflake, Message>
The messages of the channel the bot remembers.
Snowflake | null
The id of the last message sent in the channel, when known.
messages is empty unless one of your files asks for messages to be remembered: see what the bot remembers. fetchMessage() and fetchMessages() always work.

Reading from Discord

fetchMessage()

A message of the channel: from what the bot remembers, or else from Discord. Discord documentation

fetchMessages()

The latest messages of the channel, newest first. The options are a FetchMessagesOptions. Discord documentation

fetchPins()

The pinned messages of the channel, latest pin first. Discord documentation

Actions

send()

Sends a message in the channel. What it accepts is a MessageInput. Discord documentation

bulkDelete()

Deletes several messages at once. Messages older than two weeks can’t be deleted in bulk: they are left out, and their number is not counted in the result. Returns how many messages were deleted. Discord documentation

sendTyping()

Shows “the bot is typing…” for 10 seconds, or until it sends a message. Discord documentation

Waiting

They wait for what comes next in the channel, while your bot runs: a restart ends the wait. How to use them is in the guide.

waitForMessage()

Waits for the next message of the channel that fits: of a person (from), saying something (matches). Anyone’s but a bot’s by default. Resolves with the message, or null when within (one minute by default) passed first. A restart of the bot ends the wait.

collectMessages()

Gathers the messages of the channel that fit, until within (one minute by default) passed or max came. Resolves with them, in order.

Types

TextBasedChannel

Any channel messages can be sent in. It is what message.channel and interaction.channel give; isTextBased() narrows a Channel to it.

GuildTextBasedChannel

Any channel of a server messages can be sent in. It is the channel of a GuildMessage and of a command used in a server.

WaitForMessageOptions

What waitForMessage() takes.
PersonInput
Only a message of this person. Anyone but a bot by default.
string | RegExp | ((message: Message) => boolean)
Only a message that says this: a text (the same, whatever the capitals and the spaces around), a regular expression, or a function of the message.
Duration
How long to wait: '30s', '2m'. One minute by default, a second at least, a day at most.

CollectMessagesOptions

What collectMessages() takes: everything WaitForMessageOptions has, and:
number
Stops once this many messages came. No limit by default: until within.

PersonInput

A person, as a wait takes it: a user, a member, or an id.

Elsewhere