MediaChannel
classe · Source
Represents a media channel.
Extends: ThreadOnlyChannel
Properties
threads
A manager of the threads belonging to this channel Source
availableTags
The set of tags that can be used in this channel. Source
defaultReactionEmoji
The emoji to show in the add reaction button on a thread in a guild forum channel Source
defaultThreadRateLimitPerUser
The initial rate limit per user (slowmode) to set on newly created threads in a channel. Source
rateLimitPerUser
The rate limit per user (slowmode) for this channel. Source
defaultAutoArchiveDuration
The default auto archive duration for newly created threads in this channel. Source
nsfw
If this channel is considered NSFW. Source
topic
The topic of this channel. Source
defaultSortOrder
The default sort order mode used to order posts Source
guild
The guild the channel is in Source
guildId
The id of the guild the channel is in Source
permissionOverwrites
A manager of permission overwrites that belong to this channel Source
name
The name of the guild channel Source
rawPosition
The raw position of the channel from Discord Source
parentId
The id of the category parent of this channel Source
parent
The category parent of this channel Source
permissionsLocked
If the permissionOverwrites match the parent channel, null if no parent Source
position
The position of the channel Source
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. Source
deletable
Whether the channel is deletable by the client user Source
manageable
Whether the channel is manageable by the client user Source
viewable
Whether the channel is viewable by the client user Source
type
The type of the channel Source
id
The channel's id Source
flags
The flags that are applied to the channel. Source
createdTimestamp
The timestamp the channel was created at Source
createdAt
The time the channel was created at Source
deleted
Whether or not the structure has been deleted Source
partial
Whether this Channel is a partial This is always false outside of DM channels. Source
client
The client that instantiated this Source
Methods
setAvailableTags
Sets the available tags for this forum channel Parameters
| Name | Type | Description |
|---|---|---|
availableTags | Array<GuildForumTagData> | The tags to set as available in this channel |
reason? | string | Reason for changing the available tags |
Returns: Promise<this>Source
setDefaultReactionEmoji
Sets the default reaction emoji for this channel Parameters
| Name | Type | Description |
|---|---|---|
defaultReactionEmoji | DefaultReactionEmoji | The emoji to set as the default reaction emoji |
reason? | string | Reason for changing the default reaction emoji |
Returns: Promise<this>Source
setDefaultThreadRateLimitPerUser
Sets the default rate limit per user (slowmode) for new threads in this channel Parameters
| Name | Type | Description |
|---|---|---|
defaultThreadRateLimitPerUser | number | The rate limit to set on newly created threads in this channel |
reason? | string | Reason for changing the default rate limit |
Returns: Promise<this>Source
setDefaultSortOrder
Sets the default sort order mode used to order posts Parameters
| Name | Type | Description |
|---|---|---|
defaultSortOrder | SortOrderType | The default sort order mode to set on this channel |
reason? | string | Reason for changing the default sort order |
Returns: Promise<this>Source
createInvite
Creates an invite to this guild channel. Parameters
| Name | Type | Description |
|---|---|---|
options? | CreateInviteOptions | The options for creating the invite Default: {}. |
Returns: Promise<Invite>
// Create an invite to a channel
channel.createInvite()
.then(invite => console.log(`Created an invite with a code of ${invite.code}`))
.catch(console.error);fetchInvites
Fetches a collection of invites to this guild channel. Resolves with a collection mapping invites by their codes. Parameters
| Name | Type | Description |
|---|---|---|
cache? | boolean | Whether or not to cache the fetched invites Default: true. |
Returns: Promise<Collection<string, Invite>>Source
setDefaultAutoArchiveDuration
Sets the default auto archive duration for all newly created threads in this channel. Parameters
| Name | Type | Description |
|---|---|---|
defaultAutoArchiveDuration | ThreadAutoArchiveDuration | The new default auto archive duration |
reason? | string | Reason for changing the channel's default auto archive duration |
Returns: Promise<this>Source
setTopic
Sets a new topic for the guild channel. Parameters
| Name | Type | Description |
|---|---|---|
topic | string | The new topic for the guild channel |
reason? | string | Reason for changing the guild channel's topic |
Returns: Promise<this>
// 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);fetchWebhooks
Fetches all webhooks for the channel. Returns: Promise<Collection<Snowflake, Webhook>>
// Fetch webhooks
channel.fetchWebhooks()
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);createWebhook
Creates a webhook for the channel. Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the webhook |
options? | ChannelWebhookCreateOptions | Options for creating the webhook |
Returns: Promise<Webhook> — Returns the created Webhook
// 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)setRateLimitPerUser
Sets the rate limit per user (slowmode) for this channel. Parameters
| Name | Type | Description |
|---|---|---|
rateLimitPerUser | number | The new rate limit in seconds |
reason? | string | Reason for changing the channel's rate limit |
Returns: Promise<this>Source
setNSFW
Sets whether this channel is flagged as NSFW. Parameters
| Name | Type | Description |
|---|---|---|
nsfw? | boolean | Whether the channel should be considered NSFW Default: true. |
reason? | string | Reason for changing the channel's NSFW flag |
Returns: Promise<this>Source
permissionsFor
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 |
checkAdmin? | boolean | Whether having ADMINISTRATOR will return all permissions Default: true. |
Returns: Readonly<Permissions>Source
memberPermissions
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 |
checkAdmin | boolean | Whether having ADMINISTRATOR will return all permissions Default: true. |
Returns: Readonly<Permissions>Source
rolePermissions
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 |
checkAdmin | boolean | Whether having ADMINISTRATOR will return all permissions |
Returns: Readonly<Permissions>Source
lockPermissions
Locks in the permission overwrites from the parent channel. Returns: Promise<GuildChannel>Source
edit
Edits the channel. Parameters
| Name | Type | Description |
|---|---|---|
data | ChannelData | The new data for the channel |
reason? | string | Reason for editing this channel |
Returns: Promise<GuildChannel>
// Edit a channel
channel.edit({ name: 'new-channel' })
.then(console.log)
.catch(console.error);setName
Sets a new name for the guild channel. Parameters
| Name | Type | Description |
|---|---|---|
name | string | The new name for the guild channel |
reason? | string | Reason for changing the guild channel's name |
Returns: Promise<GuildChannel>
// Set a new channel name
channel.setName('not_general')
.then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
.catch(console.error);setParent
Sets the parent of this channel. Parameters
| Name | Type | Description |
|---|---|---|
channel | CategoryChannelResolvable | The category channel to set as the parent |
options? | SetParentOptions | The options for setting the parent Default: {}. |
Returns: Promise<GuildChannel>
// 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
Sets a new position for the guild channel. Parameters
| Name | Type | Description |
|---|---|---|
position | number | The new position for the guild channel |
options? | SetChannelPositionOptions | Options for setting position |
Returns: Promise<GuildChannel>
// Set a new channel position
channel.setPosition(2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);clone
Clones this channel. Parameters
| Name | Type | Description |
|---|---|---|
options? | GuildChannelCloneOptions | The options for cloning this channel |
Returns: Promise<GuildChannel>Source
equals
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 |
Returns: booleanSource
delete
Deletes this channel. Parameters
| Name | Type | Description |
|---|---|---|
reason? | string | Reason for deleting this channel |
Returns: Promise<GuildChannel>
// Delete the channel
channel.delete('making room for new channels')
.then(console.log)
.catch(console.error);toString
When concatenated with a string, this automatically returns the channel's mention instead of the Channel object. Returns: string
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);fetch
Fetches this channel. Parameters
| Name | Type | Description |
|---|---|---|
force? | boolean | Whether to skip the cache check and request the API Default: true. |
Returns: Promise<Channel>Source
isText
Indicates whether this channel is text-based. Returns: booleanSource
isVoice
Indicates whether this channel is voice-based. Returns: booleanSource
isThread
Indicates whether this channel is a ThreadChannel. Returns: booleanSource
isThreadOnly
Indicates whether this channel is ThreadOnlyChannel. Returns: booleanSource
isDirectory
Indicates whether this channel is a DirectoryChannelReturns: booleanSource