GuildTextChannel
- class GuildTextChannel
A standard text or announcement channel in a guild.
Example
const channel = await discord.fetchGuildTextChannel('1504537312841961583'); if (channel) await channel.send('Deployment finished.');
- Extends:
Properties
Property
Type
Description
nsfwIndicates whether this channel is marked as not-safe-for-work.
rateLimitPerUserSlow mode cooldown in seconds (0 = disabled).
topicThe channel topic, or
nullif not set.type0 | 5
Text and announcement channels share the text-channel API.
Methods
- async GuildTextChannel.bulkDelete(messageIds: string[], reason: string) Promise<void>
Bulk delete messages by ID (Discord limit: 2-100, older than 2 weeks fails).
- Parameters:
messageIds: Array of message IDs to delete.
reason: The reason for the audit log.
-
async GuildTextChannel.createPoll(question: string, answers: string[], duration: number, allowMultiselect: boolean) Promise<
Message> Create a poll in this channel.
- Parameters:
question: The poll question.
answers: Array of poll answers.
duration: Duration of the poll in hours.
allowMultiselect: Whether members can select multiple answers.
- Returns:
The message containing the poll.
-
async GuildTextChannel.createThread(options:
ThreadCreateOptions) Promise<ThreadChannel> Create a new thread in this channel.
- Parameters:
options: Thread creation options including name and auto-archive duration.
- Returns:
The created thread.
-
async GuildTextChannel.createThreadFromMessage(messageId: string, options:
ThreadFromMessageCreateOptions) Promise<ThreadChannel> Create a thread from an existing message.
- Parameters:
messageId: The ID of the source message.
options: Thread creation options including name and auto-archive duration.
- Returns:
The created thread.
-
async GuildTextChannel.createWebhook(options: { avatar?: string; name: string; reason?: string; }) Promise<
Webhook> Create a webhook for this channel.
- Parameters:
options: Webhook creation options including name and optional avatar.
- Returns:
The created webhook.
-
async GuildTextChannel.edit(options:
GuildTextChannelEditOptions) Promise<GuildTextChannel> Edit channel properties.
- Parameters:
options: The channel properties to update.
- Returns:
The updated channel.
-
async GuildTextChannel.fetchActiveThreads() Promise<
ThreadChannel[]> List this channel’s active threads.
-
async GuildTextChannel.fetchArchivedThreads(options:
ArchivedThreadsOptions) Promise<ArchivedThreadPage> List archived threads, newest first. Pass
type: "private"for private threads, which needs Manage Threads. PassnextBeforeback to get the next page:let page = await channel.fetchArchivedThreads({ limit: 50 }); while (page.nextBefore) { page = await channel.fetchArchivedThreads({ limit: 50, before: page.nextBefore }); }
-
async GuildTextChannel.fetchMessage(messageId: string) Promise<
Message| null> Fetch a specific message by ID, or
nullif not found.- Parameters:
messageId: The ID of the message to fetch.
- Returns:
The message, or null if not found.
-
async GuildTextChannel.fetchMessages(options:
FetchMessagesOptions) Promise<Message[]> Fetch recent messages with optional pagination.
- Parameters:
options: Optional pagination parameters.
- Returns:
Array of messages.
-
async GuildTextChannel.fetchPinnedMessages() Promise<
Message[]> Fetch all pinned messages in this channel.
- Returns:
Array of pinned messages.
-
async GuildTextChannel.fetchPins(options: { before?: string | Date; limit?: number; }) Promise<
PinPage> Fetch a page of pinned messages with Discord’s cursor-based pins API.
-
async GuildTextChannel.fetchWebhooks() Promise<
Webhook[]> Fetch all webhooks in this channel.
- Returns:
Array of webhooks.
-
async GuildTextChannel.send(content: string |
SendMessageOptions) Promise<Message> Send a message in this channel.
- Parameters:
content: The message content or send options.
- Returns:
The sent message.
-
async GuildTextChannel.setNsfw(nsfw: boolean) Promise<
GuildTextChannel> Turn the NSFW flag on or off.
- Parameters:
nsfw: Whether the channel should be NSFW.
- Returns:
The updated channel.
-
async GuildTextChannel.setSlowmode(seconds: number) Promise<
GuildTextChannel> Set the slow mode cooldown.
- Parameters:
seconds: Slow mode cooldown in seconds (0 to disable).
- Returns:
The updated channel.
-
async GuildTextChannel.setTopic(topic: string | null) Promise<
GuildTextChannel> Set the channel topic.
- Parameters:
topic: The new topic, or null to clear.
- Returns:
The updated channel.