Extends
Members
(readonly) client :Client
The client that instantiated this
Type:
- Inherited From:
- Source:
(readonly) createdAt :Date
The time the channel was created at
Type:
- Date
- Inherited From:
- Source:
(readonly) createdTimestamp :number
The timestamp the channel was created at
Type:
- number
- Inherited From:
- Source:
(readonly) deletable :boolean
Whether the channel is deletable by the client user
Type:
- boolean
- Inherited From:
- Source:
deleted :boolean
Whether the channel has been deleted
Type:
- boolean
- Inherited From:
- Source:
guild :Guild
The guild the channel is in
Type:
- Inherited From:
- Source:
id :Snowflake
The unique ID of the channel
Type:
- Inherited From:
- Source:
(readonly, nullable) lastMessage :Message
The Message object of the last message in the channel, if one was sent
Type:
- Inherited From:
- Implements:
- Source:
(nullable) lastMessageID :Snowflake
The ID of the last message sent in this channel, if one was sent
Type:
- Inherited From:
- Source:
(readonly, nullable) lastPinAt :Date
The date when the last pinned message was pinned, if there was one
Type:
- Date
- Inherited From:
- Implements:
- Source:
(nullable) lastPinTimestamp :number
The timestamp when the last pinned message was pinned, if there was one
Type:
- number
- Inherited From:
- Source:
(readonly) manageable :boolean
Whether the channel is manageable by the client user
Type:
- boolean
- Inherited From:
- Source:
(readonly) members :Collection.<Snowflake, GuildMember>
A collection of members that can see this channel, mapped by their ID
Type:
- Collection.<Snowflake, GuildMember>
- Inherited From:
- Source:
messages :MessageManager
A manager of the messages sent to this channel
Type:
- Inherited From:
- Source:
name :string
The name of the guild channel
Type:
- string
- Inherited From:
- Source:
(readonly) nsfw :boolean
If the guild considers this channel NSFW
Type:
- boolean
- Inherited From:
- Source:
(readonly, nullable) parent :CategoryChannel
The category parent of this channel
Type:
- Inherited From:
- Source:
(nullable) parentID :Snowflake
The ID of the category parent of this channel
Type:
- Inherited From:
- Source:
permissionOverwrites :Collection.<Snowflake, PermissionOverwrites>
A map of permission overwrites in this channel for roles and users
Type:
- Collection.<Snowflake, PermissionOverwrites>
- Inherited From:
- Source:
(readonly, nullable) permissionsLocked :boolean
If the permissionOverwrites match the parent channel, null if no parent
Type:
- boolean
- Inherited From:
- Source:
(readonly) position :number
The position of the channel
Type:
- number
- Inherited From:
- Source:
rateLimitPerUser :number
The ratelimit per user for this channel in seconds
Type:
- number
- Overrides:
- Source:
rawPosition :number
The raw position of the channel from discord
Type:
- number
- Inherited From:
- Source:
(nullable) topic :string
The topic of the text channel
Type:
- string
- Inherited From:
- Source:
type :string
The type of the channel, either:
* `dm` - a DM channel
* `text` - a guild text channel
* `voice` - a guild voice channel
* `category` - a guild category channel
* `news` - a guild news channel
* `store` - a guild store channel
* `unknown` - a generic channel of unknown type, could be Channel or GuildChannel
Type:
- string
- Inherited From:
- Source:
(readonly) typing :boolean
Whether or not the typing indicator is being shown in the channel
Type:
- boolean
- Inherited From:
- Implements:
- Source:
(readonly) typingCount :number
Number of times `startTyping` has been called
Type:
- number
- Inherited From:
- Implements:
- Source:
(readonly) viewable :boolean
Whether the channel is viewable by the client user
Type:
- boolean
- Inherited From:
- Source:
Methods
awaitMessages(filter, optionsopt) → {Promise.<Collection.<Snowflake, Message>>}
Similar to createMessageCollector but in promise form.
Resolves with a collection of messages that pass the specified filter.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filter |
CollectorFilter | The filter function to use | ||
options |
AwaitMessagesOptions |
<optional> |
{} | Optional options to pass to the internal collector |
- Inherited From:
- Implements:
- Source:
Returns:
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: 60000, errors: ['time'] })
.then(collected => console.log(collected.size))
.catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
bulkDelete(messages, filterOldopt) → {Promise.<Collection.<Snowflake, Message>>}
Bulk deletes given messages that are newer than two weeks.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
messages |
Collection.<Snowflake, Message> | Array.<MessageResolvable> | number | Messages or number of messages to delete | ||
filterOld |
boolean |
<optional> |
false | Filter messages to remove those which are older than two weeks automatically |
- Inherited From:
- Implements:
- Source:
Returns:
Deleted messages
Example
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
clone(optionsopt) → {Promise.<GuildChannel>}
Clones this channel.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
The options
Properties
|
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
createInvite(optionsopt) → {Promise.<Invite>}
Creates an invite to this guild channel.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
{} | Options for the invite
Properties
|
- Inherited From:
- Source:
Returns:
- Type
- Promise.<Invite>
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);
createMessageCollector(filter, optionsopt) → {MessageCollector}
Creates a Message Collector.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filter |
CollectorFilter | The filter to create the collector with | ||
options |
MessageCollectorOptions |
<optional> |
{} | The options to pass to the collector |
- Inherited From:
- Implements:
- Source:
Returns:
- Type
- MessageCollector
Example
// Create a message collector
const filter = m => m.content.includes('discord');
const collector = channel.createMessageCollector(filter, { time: 15000 });
collector.on('collect', m => console.log(`Collected ${m.content}`));
collector.on('end', collected => console.log(`Collected ${collected.size} items`));
createOverwrite(userOrRole, options, reasonopt) → {Promise.<GuildChannel>}
Overwrites the permissions for a user or role in this channel. (replaces if existent)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userOrRole |
RoleResolvable | UserResolvable | The user or role to update | |
options |
PermissionOverwriteOptions | The options for the update | |
reason |
string |
<optional> |
Reason for creating/editing this overwrite |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
Example
// Create or Replace permissions overwrites for a message author
message.channel.createOverwrite(message.author, {
SEND_MESSAGES: false
})
.then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
.catch(console.error);
createWebhook(name, optionsopt) → {Promise.<Webhook>}
Creates a webhook for the channel.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name |
string | The name of the webhook | |||||||||||||
options |
Object |
<optional> |
Options for creating the webhook
Properties
|
- Inherited From:
- Source:
Returns:
webhook The created webhook
- Type
- Promise.<Webhook>
Example
// Create a webhook for the current channel
channel.createWebhook('Snek', {
avatar: 'https://i.imgur.com/mI8XcpG.jpg',
reason: 'Needed a cool new Webhook'
})
.then(console.log)
.catch(console.error)
delete(reasonopt) → {Promise.<GuildChannel>}
Deletes this channel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
reason |
string |
<optional> |
Reason for deleting this channel |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
Example
// Delete the channel
channel.delete('making room for new channels')
.then(console.log)
.catch(console.error);
edit(data, reasonopt) → {Promise.<GuildChannel>}
Edits the channel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
ChannelData | The new data for the channel | |
reason |
string |
<optional> |
Reason for editing this channel |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
Example
// Edit a channel
channel.edit({ name: 'new-channel' })
.then(console.log)
.catch(console.error);
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.
Parameters:
Name | Type | Description |
---|---|---|
channel |
GuildChannel | Channel to compare with |
- Inherited From:
- Source:
Returns:
- Type
- boolean
fetch(forceopt) → {Promise.<Channel>}
Fetches this channel.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force |
boolean |
<optional> |
false | Whether to skip the cache check and request the API |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<Channel>
fetchInvites() → {Promise.<Collection.<string, Invite>>}
Fetches a collection of invites to this guild channel.
Resolves with a collection mapping invites by their codes.
- Inherited From:
- Source:
Returns:
- Type
- Promise.<Collection.<string, Invite>>
fetchWebhooks() → {Promise.<Collection.<Snowflake, Webhook>>}
Fetches all webhooks for the channel.
- Inherited From:
- Source:
Returns:
Example
// Fetch webhooks
channel.fetchWebhooks()
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);
isText() → {boolean}
Indicates whether this channel is text-based.
- Inherited From:
- Source:
Returns:
- Type
- boolean
lockPermissions() → {Promise.<GuildChannel>}
Locks in the permission overwrites from the parent channel.
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
(private) memberPermissions(member) → {Readonly.<Permissions>}
Gets the overall set of permissions for a member in this channel, taking into account channel overwrites.
Parameters:
Name | Type | Description |
---|---|---|
member |
GuildMember | The member to obtain the overall permissions for |
- Inherited From:
- Source:
Returns:
- Type
- Readonly.<Permissions>
overwritePermissions(overwrites, reasonopt) → {Promise.<GuildChannel>}
Replaces the permission overwrites in this channel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
overwrites |
Array.<OverwriteResolvable> | Collection.<Snowflake, OverwriteResolvable> | Permission overwrites the channel gets updated with | |
reason |
string |
<optional> |
Reason for updating the channel overwrites |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
Example
channel.overwritePermissions([
{
id: message.author.id,
deny: ['VIEW_CHANNEL'],
},
], 'Needed to change permissions');
permissionsFor(memberOrRole) → {Readonly.<Permissions>}
Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites.
Parameters:
Name | Type | Description |
---|---|---|
memberOrRole |
GuildMemberResolvable | RoleResolvable | The member or role to obtain the overall permissions for |
- Inherited From:
- Source:
Returns:
- Type
- Readonly.<Permissions>
(private) rolePermissions(role) → {Readonly.<Permissions>}
Gets the overall set of permissions for a role in this channel, taking into account channel overwrites.
Parameters:
Name | Type | Description |
---|---|---|
role |
Role | The role to obtain the overall permissions for |
- Inherited From:
- Source:
Returns:
- Type
- Readonly.<Permissions>
send(contentopt, optionsopt) → {Promise.<(Message|Array.<Message>)>}
Sends a message to this channel.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
content |
StringResolvable | APIMessage |
<optional> |
'' | The content to send |
options |
MessageOptions | MessageAdditions |
<optional> |
{} | The options to provide |
- Inherited From:
- Implements:
- Source:
Returns:
Examples
// 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'
}]
})
.then(console.log)
.catch(console.error);
// Send an embed with a local image inside
channel.send('This is an embed', {
embed: {
thumbnail: {
url: 'attachment://file.jpg'
}
},
files: [{
attachment: 'entire/path/to/file.jpg',
name: 'file.jpg'
}]
})
.then(console.log)
.catch(console.error);
setName(name, reasonopt) → {Promise.<GuildChannel>}
Sets a new name for the guild channel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | The new name for the guild channel | |
reason |
string |
<optional> |
Reason for changing the guild channel's name |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
Example
// Set a new channel name
channel.setName('not_general')
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);
setNSFW(nsfw, reasonopt) → {Promise.<TextChannel>}
Sets whether this channel is flagged as NSFW.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
nsfw |
boolean | Whether the channel should be considered NSFW | |
reason |
string |
<optional> |
Reason for changing the channel's NSFW flag |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<TextChannel>
setParent(channel, optionsopt) → {Promise.<GuildChannel>}
Sets the category parent of this channel.
Parameters:
Name | Type | Attributes | Default | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
channel |
CategoryChannel | Snowflake | Parent channel | |||||||||||||||||
options |
Object |
<optional> |
{} | Options to pass
Properties
|
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
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);
setPosition(position, optionsopt) → {Promise.<GuildChannel>}
Sets a new position for the guild channel.
Parameters:
Name | Type | Attributes | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
position |
number | The new position for the guild channel | ||||||||||||||||
options |
Object |
<optional> |
Options for setting position
Properties
|
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
Example
// Set a new channel position
channel.setPosition(2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);
setRateLimitPerUser(rateLimitPerUser, reasonopt) → {Promise.<TextChannel>}
Sets the rate limit per user for this channel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
rateLimitPerUser |
number | The new ratelimit in seconds | |
reason |
string |
<optional> |
Reason for changing the channel's ratelimits |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<TextChannel>
setTopic(topic, reasonopt) → {Promise.<GuildChannel>}
Sets a new topic for the guild channel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
topic |
string | The new topic for the guild channel | |
reason |
string |
<optional> |
Reason for changing the guild channel's topic |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
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);
startTyping(countopt) → {Promise}
Starts a typing indicator in the channel.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
count |
number |
<optional> |
1 | The number of times startTyping should be considered to have been called |
- Inherited From:
- Implements:
- Source:
Returns:
Resolves once the bot stops typing gracefully, or rejects when an error occurs
- Type
- Promise
Examples
// Start typing in a channel, or increase the typing count by one
channel.startTyping();
// Start typing in a channel with a typing count of five, or set it to five
channel.startTyping(5);
stopTyping(forceopt)
Stops the typing indicator in the channel.
The indicator will only stop if this is called as many times as startTyping().
It can take a few seconds for the client user to stop typing.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
force |
boolean |
<optional> |
false | Whether or not to reset the call count and force the indicator to stop |
- Inherited From:
- Implements:
- Source:
Examples
// Reduce the typing count by one and stop typing if it reached 0
channel.stopTyping();
// Force typing to fully stop regardless of typing count
channel.stopTyping(true);
toString() → {string}
When concatenated with a string, this automatically returns the channel's mention instead of the Channel object.
- Inherited From:
- Source:
Returns:
- Type
- string
Example
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);
updateOverwrite(userOrRole, options, reasonopt) → {Promise.<GuildChannel>}
Updates Overwrites for a user or role in this channel. (creates if non-existent)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userOrRole |
RoleResolvable | UserResolvable | The user or role to update | |
options |
PermissionOverwriteOptions | The options for the update | |
reason |
string |
<optional> |
Reason for creating/editing this overwrite |
- Inherited From:
- Source:
Returns:
- Type
- Promise.<GuildChannel>
Example
// Update or Create permission overwrites for a message author
message.channel.updateOverwrite(message.author, {
SEND_MESSAGES: false
})
.then(channel => console.log(channel.permissionOverwrites.get(message.author.id)))
.catch(console.error);