BaseGuildTextChannel

export class BaseGuildTextChannel extends GuildChannel
export class BaseGuildTextChannel extends GuildChannel
Represents a text-based guild channel on Discord.
constructor(guild, data?, client?, immediatePatch?)
Constructs a new instance of the BaseGuildTextChannel class
NameTypeOptionalDescription
guildGuildNoNone
dataRawGuildChannelDataYesNone
clientClient<true>YesNone
immediatePatchbooleanYesNone
Readonly
client:Client<true>
The client that instantiated this
Inherited from Base
Readonly
createdAt:Date
The time the channel was created at
Inherited from GuildChannel
Readonly
createdTimestamp:number
The timestamp the channel was created at
Inherited from GuildChannel
defaultAutoArchiveDuration?:ThreadAutoArchiveDuration
The default auto archive duration for newly created threads in this channel
defaultThreadRateLimitPerUser:number | null
The initial rate limit per user (slowmode) to set on newly created threads in a channel.
Readonly
deletable:boolean
Whether the channel is deletable by the client user
Inherited from GuildChannel
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
guild:Guild
The guild the channel is in
Inherited from GuildChannel
guildId:Snowflake
The id of the guild the channel is in
Inherited from GuildChannel
The channel's id
Inherited from BaseChannel
Readonly
lastMessage?:Message
The Message object of the last message in the channel, if one was sent
lastMessageId?:Snowflake
The last message id sent in the channel, if one was sent
Readonly
lastPinAt?:Date
The date when the last pinned message was pinned, if there was one
lastPinTimestamp?:number
The timestamp when the last pinned message was pinned, if there was one
Readonly
manageable:boolean
Whether the channel is manageable by the client user
Inherited from GuildChannel
Readonly
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
A manager of the messages sent to this channel
name:string
The name of the guild channel
Inherited from GuildChannel
nsfw:boolean
If the guild considers this channel NSFW
Readonly
The category parent of this channel
Inherited from GuildChannel
parentId:Snowflake | null
The id of the category parent of this channel
Inherited from GuildChannel
Readonly
partial:false
Whether this Channel is a partial This is always false outside of DM channels.
Inherited from BaseChannel
permissionOverwrites:PermissionOverwriteManager
A manager of permission overwrites that belong to this channel
Inherited from GuildChannel
Readonly
permissionsLocked:boolean | null
If the permissionOverwrites match the parent channel, null if no parent
Inherited from GuildChannel
Readonly
position:number
The position of the channel
Inherited from GuildChannel
rateLimitPerUser:number | null
rawPosition:number
The raw position of the channel from Discord
Inherited from GuildChannel
A manager of the threads belonging to this channel
topic:string | null
The topic of the text channel
The type of the channel
Inherited from GuildChannel
Readonly
url:string
The URL to the channel
Inherited from BaseChannel
Readonly
viewable:boolean
Whether the channel is viewable by the client user
Inherited from GuildChannel
Readonly
lastMessage:Message | null
Inherited from TextBasedChannelFields
lastMessageId:Snowflake | null
Inherited from TextBasedChannelFields
Readonly
lastPinAt:Date | null
Inherited from TextBasedChannelFields
lastPinTimestamp:number | null
Inherited from TextBasedChannelFields
awaitMessageComponent(options?):Promise<MessageComponentInteraction>
Collects a single component interaction that passes the filter. The Promise will reject if the time expires.
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsAwaitMessageComponentOptionsYesOptions to pass to the internal collector
awaitMessages(options?):Promise<Collection<Snowflake, Message>>
Similar to createMessageCollector but in promise form. Resolves with a collection of messages that pass the specified filter.
Example
// 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.`));
// 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.`));
NameTypeOptionalDescription
optionsAwaitMessagesOptionsYesOptional options to pass to the internal collector
bulkDelete(messages, filterOld?):Promise<Collection<Snowflake, (Message|undefined)>>
Bulk deletes given messages that are newer than two weeks.
Returns
Returns the deleted messages *
Example
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
NameTypeOptionalDescription
messagesCollection<Snowflake, Message> | Array<MessageResolvable> | numberNoMessages or number of messages to delete
filterOldbooleanYesFilter messages to remove those which are older than two weeks automatically
clone(options?):Promise<this>
Clones this channel.
NameTypeOptionalDescription
optionsGuildChannelCloneOptionsYesThe options for cloning this channel
Inherited from GuildChannel
createInvite(options?):Promise<Invite>
Creates an invite to this guild channel.
Example
// Create an invite to a channel
channel.createInvite()
.then(invite => console.log(`Created an invite with a code of ${invite.code}`))
.catch(console.error);
// Create an invite to a channel
channel.createInvite()
.then(invite => console.log(`Created an invite with a code of ${invite.code}`))
.catch(console.error);
NameTypeOptionalDescription
optionsInviteCreateOptionsYesThe options for creating the invite
createMessageCollector(options?):MessageCollector
Creates a Message Collector.
Example
// 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`));
// 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`));
NameTypeOptionalDescription
optionsMessageCollectorOptionsYesThe options to pass to the collector
createMessageComponentCollector(options?):InteractionCollector
Creates a component interaction collector.
Example
// 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`));
// 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`));
NameTypeOptionalDescription
optionsMessageComponentCollectorOptionsYesOptions to send to the collector
createWebhook(options?):Promise<Webhook>
Creates a webhook for the channel.
Returns
Returns the created Webhook *
Example
// 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)
// 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)
NameTypeOptionalDescription
optionsChannelWebhookCreateOptionsYesOptions for creating the webhook
delete(reason?):Promise<this>
Deletes this channel.
Example
// Delete the channel
channel.delete('making room for new channels')
.then(console.log)
.catch(console.error);
// Delete the channel
channel.delete('making room for new channels')
.then(console.log)
.catch(console.error);
NameTypeOptionalDescription
reasonstringYesReason for deleting this channel
Inherited from GuildChannel
edit(options):Promise<this>
Edits the channel.
Example
// Edit a channel
channel.edit({ name: 'new-channel' })
.then(console.log)
.catch(console.error);
// Edit a channel
channel.edit({ name: 'new-channel' })
.then(console.log)
.catch(console.error);
NameTypeOptionalDescription
optionsGuildChannelEditOptionsNoThe options to provide
Inherited from GuildChannel
equals(channel):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.
NameTypeOptionalDescription
channelGuildChannelNoChannel to compare with
Inherited from GuildChannel
fetch(force?):Promise<this>
Fetches this channel.
NameTypeOptionalDescription
forcebooleanYesWhether to skip the cache check and request the API
Inherited from BaseChannel
fetchInvites(cache?):Promise<Collection<string, Invite>>
Fetches a collection of invites to this guild channel. Resolves with a collection mapping invites by their codes.
NameTypeOptionalDescription
cachebooleanYesWhether or not to cache the fetched invites
fetchWebhooks():Promise<Collection<Snowflake, Webhook>>
Fetches all webhooks for the channel.
Example
// Fetch webhooks
channel.fetchWebhooks()
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);
// Fetch webhooks
channel.fetchWebhooks()
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);
Indicates whether this channel is DM-based (either a or a PartialGroupDMChannel).
Inherited from BaseChannel
isSendable():this is SendableChannels
Indicates whether this channel is sendable.
Inherited from BaseChannel
isTextBased():this is GuildBasedChannel & TextBasedChannel
Indicates whether this channel is text-based.
Inherited from GuildChannel
isThread():this is AnyThreadChannel
Indicates whether this channel is a .
Inherited from BaseChannel
isThreadOnly():this is ThreadOnlyChannel
Indicates whether this channel is .
Inherited from BaseChannel
isVoiceBased():this is VoiceBasedChannel
Indicates whether this channel is .
Inherited from BaseChannel
lockPermissions():Promise<this>
Locks in the permission overwrites from the parent channel.
Inherited from GuildChannel
permissionsFor(memberOrRole, checkAdmin?):Readonly<PermissionsBitField>
Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites.
Returns
NameTypeOptionalDescription
memberOrRoleGuildMember | RoleNoThe member or role to obtain the overall permissions for
checkAdminbooleanYesWhether having the PermissionFlagsBits.Administrator permission will return all permissions
send(options):Promise<Message>
Sends a message to this channel.
Example
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
// Send a basic message
channel.send('hello!')
.then(message => console.log(`Sent message: ${message.content}`))
.catch(console.error);
Example
// 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 remote file
channel.send({
files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
})
.then(console.log)
.catch(console.error);
Example
// 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);
// 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);
NameTypeOptionalDescription
optionsstring | MessagePayload | MessageCreateOptionsNoThe options to provide
sendTyping():Promise<void>
Sends a typing indicator in the channel.
Returns
Resolves upon the typing status being sent *
Example
// Start typing in a channel
channel.sendTyping();
// Start typing in a channel
channel.sendTyping();
setDefaultAutoArchiveDuration(defaultAutoArchiveDuration, reason?):Promise<this>
Sets the default auto archive duration for all newly created threads in this channel.
NameTypeOptionalDescription
defaultAutoArchiveDurationThreadAutoArchiveDurationNoThe new default auto archive duration
reasonstringYesReason for changing the channel's default auto archive duration
setName(name, reason?):Promise<this>
Sets a new name for the guild channel.
Example
// Set a new channel name
channel.setName('not_general')
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);
// Set a new channel name
channel.setName('not_general')
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);
NameTypeOptionalDescription
namestringNoThe new name for the guild channel
reasonstringYesReason for changing the guild channel's name
Inherited from GuildChannel
setNSFW(nsfw?, reason?):Promise<this>
Sets whether this channel is flagged as NSFW.
NameTypeOptionalDescription
nsfwbooleanYesWhether the channel should be considered NSFW
reasonstringYesReason for changing the channel's NSFW flag
setParent(channel, options?):Promise<this>
Sets the parent of this channel.
Example
// 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);
// 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);
NameTypeOptionalDescription
channelCategoryChannelResolvable | nullNoThe category channel to set as the parent
optionsSetParentOptionsYesThe options for setting the parent
Inherited from GuildChannel
setPosition(position, options?):Promise<this>
Sets a new position for the guild channel.
Example
// Set a new channel position
channel.setPosition(2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);
// Set a new channel position
channel.setPosition(2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);
NameTypeOptionalDescription
positionnumberNoThe new position for the guild channel
optionsSetChannelPositionOptionsYesOptions for setting position
Inherited from GuildChannel
setRateLimitPerUser(rateLimitPerUser, reason?):Promise<this>
Sets the rate limit per user (slowmode) for this channel.
NameTypeOptionalDescription
rateLimitPerUsernumberNoThe new rate limit in seconds
reasonstringYesReason for changing the channel's rate limit
setTopic(topic, reason?):Promise<this>
Sets a new topic for the guild channel.
Example
// 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);
// 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);
NameTypeOptionalDescription
topicstring | nullNoThe new topic for the guild channel
reasonstringYesReason for changing the guild channel's topic
setType(type, reason?):Promise<TextChannel>
Sets the type of this channel. Only conversion between TextChannel and AnnouncementChannel is supported.
NameTypeOptionalDescription
typeChannelType.GuildTextNoThe new channel type
reasonstringYesReason for changing the channel's type
toJSON(...props):unknown
NameTypeOptionalDescription
...propsRecord<string, boolean | string>[]NoNone
Inherited from Base
toString():ChannelMention
When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
Example
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);
Inherited from GuildChannel
valueOf():string
awaitMessageComponent(options?):Promise<MappedInteractionTypes[ComponentType]>
NameConstraintsOptionalDefaultDescription
ComponentTypeMessageComponentTypeNoNone
NameTypeOptionalDescription
optionsAwaitMessageCollectorOptionsParams<ComponentType, true>YesNone
Inherited from TextBasedChannelFields
awaitMessages(options?):Promise<Collection<Snowflake, Message>>
NameTypeOptionalDescription
optionsAwaitMessagesOptionsYesNone
Inherited from TextBasedChannelFields
bulkDelete(messages, filterOld?):Promise<Collection<Snowflake, Message | PartialMessage | undefined>>
NameTypeOptionalDescription
messagesCollection<Snowflake, Message> | readonly MessageResolvable[] | numberNoNone
filterOldbooleanYesNone
Inherited from TextBasedChannelFields
createMessageCollector(options?):MessageCollector
NameTypeOptionalDescription
optionsMessageCollectorOptionsYesNone
Inherited from TextBasedChannelFields
createMessageComponentCollector(options?):InteractionCollector<MappedInteractionTypes[ComponentType]>
NameConstraintsOptionalDefaultDescription
ComponentTypeMessageComponentTypeNoNone
NameTypeOptionalDescription
optionsMessageChannelCollectorOptionsParams<ComponentType, true>YesNone
Inherited from TextBasedChannelFields
createWebhook(options):Promise<Webhook<WebhookType.Incoming>>
NameTypeOptionalDescription
optionsChannelWebhookCreateOptionsNoNone
Inherited from TextBasedChannelFields
send(options):Promise<Message<InGuild>>
NameTypeOptionalDescription
optionsstring | MessagePayload | MessageCreateOptionsNoNone
Inherited from PartialTextBasedChannelFields
sendTyping():Promise<void>
setNSFW(nsfw?, reason?):Promise<this>
NameTypeOptionalDescription
nsfwbooleanYesNone
reasonstringYesNone
Inherited from TextBasedChannelFields
setRateLimitPerUser(rateLimitPerUser, reason?):Promise<this>
NameTypeOptionalDescription
rateLimitPerUsernumberNoNone
reasonstringYesNone
Inherited from TextBasedChannelFields