class BaseGuildTextChannel
extends
GuildChannelexport class BaseGuildTextChannel extends GuildChannel
Represents a text-based guild channel on Discord.
readonlynumber createdTimestamp :
The timestamp the channel was created at
Inherited from: GuildChannel
optionalThreadAutoArchiveDuration defaultAutoArchiveDuration? :
The default auto archive duration for newly created threads in this channel
The initial rate limit per user (slowmode) to set on newly created threads in a channel.
readonlyboolean deletable :
Whether the channel is deletable by the client user
Inherited from: GuildChannel
Readonly<ChannelFlagsBitField> flags :
The flags that are applied to the channel. This is only null
in a PartialGroupDMChannel. In all other cases, it is not null
.
Inherited from: GuildChannel
readonlyoptionalMessage lastMessage? :
The Message object of the last message in the channel, if one was sent
optionalSnowflake lastMessageId? :
The last message id sent in the channel, if one was sent
readonlyoptionalDate lastPinAt? :
The date when the last pinned message was pinned, if there was one
optionalnumber lastPinTimestamp? :
The timestamp when the last pinned message was pinned, if there was one
readonlyboolean manageable :
Whether the channel is manageable by the client user
Inherited from: GuildChannel
readonlyCollection<Snowflake, GuildMember> members :
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.
Inherited from: GuildChannel
GuildMessageManager messages :
A manager of the messages sent to this channel
boolean nsfw :
If the guild considers this channel NSFW
readonlyCategoryChannel | null parent :
The category parent of this channel
Inherited from: GuildChannel
The id of the category parent of this channel
Inherited from: GuildChannel
Whether this Channel is a partial This is always false outside of DM channels.
Inherited from: BaseChannel
PermissionOverwriteManager permissionOverwrites :
A manager of permission overwrites that belong to this channel
Inherited from: GuildChannel
If the permissionOverwrites match the parent channel, null if no parent
Inherited from: GuildChannel
A manager of the threads belonging to this channel
Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM> type :
The type of the channel
Inherited from: GuildChannel
readonlyboolean viewable :
Whether the channel is viewable by the client user
Inherited from: GuildChannel
Inherited from: TextBasedChannelFields
Inherited from: TextBasedChannelFields
Inherited from: TextBasedChannelFields
Inherited from: TextBasedChannelFields
If<InGuild, GuildMessageManager, DMMessageManager> messages :
Inherited from: TextBasedChannelFields
awaitMessageComponentoptions?: AwaitMessageComponentOptions) : Promise<MessageComponentInteraction> (
Collects a single component interaction that passes the filter. The Promise will reject if the time expires.
// Collect a message component interaction
const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
channel.awaitMessageComponent({ filter, time: 15_000 })
.then(interaction => console.log(`${interaction.customId} was clicked!`))
.catch(console.error);
awaitMessagesoptions?: AwaitMessagesOptions) : Promise<Collection<Snowflake, Message>> (
Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter.
// Await !vote messages
const filter = m => m.content.startsWith('!vote');
// Errors: ['time'] treats ending because of the time limit as an error
channel.awaitMessages({ filter, max: 4, time: 60_000, errors: ['time'] })
.then(collected => console.log(collected.size))
.catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
bulkDeletemessages: Collection<Snowflake, Message> | Array<MessageResolvable> | numberfilterOld?: boolean) : Promise<Collection<Snowflake, (Message|undefined)>> (
Bulk deletes given messages that are newer than two weeks.
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
Returns: Returns the deleted messages *
cloneoptions?: GuildChannelCloneOptions) : Promise<this> (
Clones this channel.
Inherited from: GuildChannel
createInviteoptions?: InviteCreateOptions) : Promise<Invite> (
Creates an invite to this guild channel.
// Create an invite to a channel
channel.createInvite()
.then(invite => console.log(`Created an invite with a code of ${invite.code}`))
.catch(console.error);
createMessageCollectoroptions?: MessageCollectorOptions) : MessageCollector (
Creates a Message Collector.
// Create a message collector
const filter = message => message.content.includes('discord');
const collector = channel.createMessageCollector({ filter, time: 15_000 });
collector.on('collect', message => console.log(`Collected ${message.content}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));
createMessageComponentCollectoroptions?: MessageComponentCollectorOptions) : InteractionCollector (
Creates a component interaction collector.
// Create a button interaction collector
const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
const collector = channel.createMessageComponentCollector({ filter, time: 15_000 });
collector.on('collect', interaction => console.log(`Collected ${interaction.customId}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));
createWebhookoptions?: ChannelWebhookCreateOptions) : Promise<Webhook> (
Creates a webhook for the channel.
// Create a webhook for the current channel
channel.createWebhook({
name: 'Snek',
avatar: 'https://i.imgur.com/mI8XcpG.jpg',
reason: 'Needed a cool new Webhook'
})
.then(console.log)
.catch(console.error)
Returns: Returns the created Webhook *
Deletes this channel.
// Delete the channel
channel.delete('making room for new channels')
.then(console.log)
.catch(console.error);
Inherited from: GuildChannel
editoptions: GuildChannelEditOptions) : Promise<this> (
Edits the channel.
// Edit a channel
channel.edit({ name: 'new-channel' })
.then(console.log)
.catch(console.error);
Inherited from: GuildChannel
equalschannel: 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.
Inherited from: GuildChannel
fetchInvitescache?: boolean) : Promise<Collection<string, Invite>> (
Fetches a collection of invites to this guild channel. Resolves with a collection mapping invites by their codes.
fetchWebhooksPromise<Collection<Snowflake, Webhook>> () :
Fetches all webhooks for the channel.
// Fetch webhooks
channel.fetchWebhooks()
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);
isDMBasedthis is PartialGroupDMChannel | DMChannel | PartialDMChannel () :
Indicates whether this channel is DM-based (either a DMChannel or a PartialGroupDMChannel).
Inherited from: BaseChannel
isTextBasedthis is GuildBasedChannel & TextBasedChannel () :
Indicates whether this channel is TextBasedChannels.
Inherited from: GuildChannel
isThreadthis is AnyThreadChannel () :
Indicates whether this channel is a ThreadChannel.
Inherited from: BaseChannel
isThreadOnlythis is ThreadOnlyChannel () :
Indicates whether this channel is thread-only.
Inherited from: BaseChannel
isVoiceBasedthis is VoiceBasedChannel () :
Indicates whether this channel is voice-based.
Inherited from: BaseChannel
lockPermissionsPromise<this> () :
Locks in the permission overwrites from the parent channel.
Inherited from: GuildChannel
permissionsFormemberOrRole: GuildMember | RolecheckAdmin?: boolean) : Readonly<PermissionsBitField> (
Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites.
sendoptions: string | MessagePayload | MessageCreateOptions) : Promise<Message> (
Sends a message to this channel.
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
// Send a remote file
channel.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);
// Send a local file
channel.send({
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg',
description: 'A description of the file'
}]
})
.then(console.log)
.catch(console.error);
Sends a typing indicator in the channel.
// Start typing in a channel
channel.sendTyping();
Returns: Resolves upon the typing status being sent *
setDefaultAutoArchiveDurationdefaultAutoArchiveDuration: ThreadAutoArchiveDurationreason?: string) : Promise<this> (
Sets the default auto archive duration for all newly created threads in this channel.
Sets a new name for the guild channel.
// Set a new channel name
channel.setName('not_general')
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);
Inherited from: GuildChannel
Sets whether this channel is flagged as NSFW.
setParentchannel: CategoryChannelResolvable | nulloptions?: SetParentOptions) : Promise<this> (
Sets the parent of this channel.
// 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);
Inherited from: GuildChannel
setPositionposition: numberoptions?: SetChannelPositionOptions) : Promise<this> (
Sets a new position for the guild channel.
// Set a new channel position
channel.setPosition(2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);
Inherited from: GuildChannel
Sets the rate limit per user (slowmode) for this channel.
Sets a new topic for the guild channel.
// 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);
setTypetype: ChannelType.GuildTextreason?: string) : Promise<TextChannel> (
Sets the type of this channel. Only conversion between TextChannel and NewsChannel is supported.
toStringChannelMention () :
When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);
Inherited from: GuildChannel
awaitMessageComponentComponentType extends MessageComponentType
>(options?: AwaitMessageCollectorOptionsParams<ComponentType, true>) : Promise<MappedInteractionTypes[ComponentType]> <
ComponentType extends MessageComponentType
Inherited from: TextBasedChannelFields
awaitMessagesoptions?: AwaitMessagesOptions) : Promise<Collection<Snowflake, Message>> (
Inherited from: TextBasedChannelFields
bulkDeletemessages: Collection<Snowflake, Message> | readonly MessageResolvable[] | numberfilterOld?: boolean) : Promise<Collection<Snowflake, Message | PartialMessage | undefined>> (
Inherited from: TextBasedChannelFields
createMessageCollectoroptions?: MessageCollectorOptions) : MessageCollector (
Inherited from: TextBasedChannelFields
createMessageComponentCollectorComponentType extends MessageComponentType
>(options?: MessageChannelCollectorOptionsParams<ComponentType, true>) : InteractionCollector<MappedInteractionTypes[ComponentType]> <
ComponentType extends MessageComponentType
Inherited from: TextBasedChannelFields
createWebhookoptions: ChannelWebhookCreateOptions) : Promise<Webhook<WebhookType.Incoming>> (
Inherited from: TextBasedChannelFields
fetchWebhooksPromise<Collection<Snowflake, Webhook<WebhookType.ChannelFollower | WebhookType.Incoming>>> () :
Inherited from: TextBasedChannelFields
sendoptions: string | MessagePayload | MessageCreateOptions) : Promise<Message<InGuild>> (
Inherited from: PartialTextBasedChannelFields
Inherited from: TextBasedChannelFields
Inherited from: TextBasedChannelFields
Inherited from: TextBasedChannelFields