Skip to content

MediaChannel

classe · Source

Represents a media channel.

Extends: ThreadOnlyChannel

Properties

threads

threads: GuildForumThreadManager

A manager of the threads belonging to this channel Source

availableTags

availableTags: Array<GuildForumTag>

The set of tags that can be used in this channel. Source

defaultReactionEmoji

nullable

defaultReactionEmoji: DefaultReactionEmoji

The emoji to show in the add reaction button on a thread in a guild forum channel Source

defaultThreadRateLimitPerUser

nullable

defaultThreadRateLimitPerUser: number

The initial rate limit per user (slowmode) to set on newly created threads in a channel. Source

rateLimitPerUser

nullable

rateLimitPerUser: number

The rate limit per user (slowmode) for this channel. Source

defaultAutoArchiveDuration

nullable

defaultAutoArchiveDuration: ThreadAutoArchiveDuration

The default auto archive duration for newly created threads in this channel. Source

nsfw

nsfw: boolean

If this channel is considered NSFW. Source

topic

nullable

topic: string

The topic of this channel. Source

defaultSortOrder

nullable

defaultSortOrder: SortOrderType

The default sort order mode used to order posts Source

guild

guild: Guild

The guild the channel is in Source

guildId

guildId: Snowflake

The id of the guild the channel is in Source

permissionOverwrites

permissionOverwrites: PermissionOverwriteManager

A manager of permission overwrites that belong to this channel Source

name

name: string

The name of the guild channel Source

rawPosition

rawPosition: number

The raw position of the channel from Discord Source

parentId

nullable

parentId: Snowflake

The id of the category parent of this channel Source

parent

readonly · nullable

parent: CategoryChannel

The category parent of this channel Source

permissionsLocked

readonly · nullable

permissionsLocked: boolean

If the permissionOverwrites match the parent channel, null if no parent Source

position

readonly

position: number

The position of the channel Source

members

readonly

members: Collection<Snowflake, GuildMember>

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

readonly

deletable: boolean

Whether the channel is deletable by the client user Source

manageable

readonly

manageable: boolean

Whether the channel is manageable by the client user Source

viewable

readonly

viewable: boolean

Whether the channel is viewable by the client user Source

type

type: ChannelType

The type of the channel Source

id

id: Snowflake

The channel's id Source

flags

nullable

flags: Readonly<ChannelFlags>

The flags that are applied to the channel. Source

createdTimestamp

readonly

createdTimestamp: number

The timestamp the channel was created at Source

createdAt

readonly

createdAt: Date

The time the channel was created at Source

deleted

deprecated

deleted: boolean

Whether or not the structure has been deleted Source

partial

readonly

partial: boolean

Whether this Channel is a partial This is always false outside of DM channels. Source

client

readonly

client: Client

The client that instantiated this Source

Methods

setAvailableTags

setAvailableTags(availableTags: Array<GuildForumTagData>, reason?: string): Promise<this>

Sets the available tags for this forum channel Parameters

NameTypeDescription
availableTagsArray<GuildForumTagData>The tags to set as available in this channel
reason?stringReason for changing the available tags

Returns: Promise<this>Source

setDefaultReactionEmoji

setDefaultReactionEmoji(defaultReactionEmoji: DefaultReactionEmoji, reason?: string): Promise<this>

Sets the default reaction emoji for this channel Parameters

NameTypeDescription
defaultReactionEmojiDefaultReactionEmojiThe emoji to set as the default reaction emoji
reason?stringReason for changing the default reaction emoji

Returns: Promise<this>Source

setDefaultThreadRateLimitPerUser

setDefaultThreadRateLimitPerUser(defaultThreadRateLimitPerUser: number, reason?: string): Promise<this>

Sets the default rate limit per user (slowmode) for new threads in this channel Parameters

NameTypeDescription
defaultThreadRateLimitPerUsernumberThe rate limit to set on newly created threads in this channel
reason?stringReason for changing the default rate limit

Returns: Promise<this>Source

setDefaultSortOrder

setDefaultSortOrder(defaultSortOrder: SortOrderType, reason?: string): Promise<this>

Sets the default sort order mode used to order posts Parameters

NameTypeDescription
defaultSortOrderSortOrderTypeThe default sort order mode to set on this channel
reason?stringReason for changing the default sort order

Returns: Promise<this>Source

createInvite

createInvite(options?: CreateInviteOptions): Promise<Invite>

Creates an invite to this guild channel. Parameters

NameTypeDescription
options?CreateInviteOptionsThe options for creating the invite Default: {}.

Returns: Promise<Invite>

js
// Create an invite to a channel
channel.createInvite()
  .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
  .catch(console.error);

Source

fetchInvites

fetchInvites(cache?: boolean): Promise<Collection<string, Invite>>

Fetches a collection of invites to this guild channel. Resolves with a collection mapping invites by their codes. Parameters

NameTypeDescription
cache?booleanWhether or not to cache the fetched invites Default: true.

Returns: Promise<Collection<string, Invite>>Source

setDefaultAutoArchiveDuration

setDefaultAutoArchiveDuration(defaultAutoArchiveDuration: ThreadAutoArchiveDuration, reason?: string): Promise<this>

Sets the default auto archive duration for all newly created threads in this channel. Parameters

NameTypeDescription
defaultAutoArchiveDurationThreadAutoArchiveDurationThe new default auto archive duration
reason?stringReason for changing the channel's default auto archive duration

Returns: Promise<this>Source

setTopic

setTopic(topic: string, reason?: string): Promise<this>

Sets a new topic for the guild channel. Parameters

NameTypeDescription
topicstringThe new topic for the guild channel
reason?stringReason for changing the guild channel's topic

Returns: Promise<this>

js
// 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);

Source

fetchWebhooks

fetchWebhooks(): Promise<Collection<Snowflake, Webhook>>

Fetches all webhooks for the channel. Returns: Promise<Collection<Snowflake, Webhook>>

js
// Fetch webhooks
channel.fetchWebhooks()
  .then(hooks => console.log(`This channel has ${hooks.size} hooks`))
  .catch(console.error);

Source

createWebhook

createWebhook(name: string, options?: ChannelWebhookCreateOptions): Promise<Webhook>

Creates a webhook for the channel. Parameters

NameTypeDescription
namestringThe name of the webhook
options?ChannelWebhookCreateOptionsOptions for creating the webhook

Returns: Promise<Webhook> — Returns the created Webhook

js
// 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)

Source

setRateLimitPerUser

setRateLimitPerUser(rateLimitPerUser: number, reason?: string): Promise<this>

Sets the rate limit per user (slowmode) for this channel. Parameters

NameTypeDescription
rateLimitPerUsernumberThe new rate limit in seconds
reason?stringReason for changing the channel's rate limit

Returns: Promise<this>Source

setNSFW

setNSFW(nsfw?: boolean, reason?: string): Promise<this>

Sets whether this channel is flagged as NSFW. Parameters

NameTypeDescription
nsfw?booleanWhether the channel should be considered NSFW Default: true.
reason?stringReason for changing the channel's NSFW flag

Returns: Promise<this>Source

permissionsFor

permissionsFor(memberOrRole: GuildMemberResolvable | RoleResolvable, checkAdmin?: boolean): Readonly<Permissions>

Gets the overall set of permissions for a member or role in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
memberOrRoleGuildMemberResolvable | RoleResolvableThe member or role to obtain the overall permissions for
checkAdmin?booleanWhether having ADMINISTRATOR will return all permissions Default: true.

Returns: Readonly<Permissions>Source

memberPermissions

private

memberPermissions(member: GuildMember, checkAdmin: boolean): Readonly<Permissions>

Gets the overall set of permissions for a member in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
memberGuildMemberThe member to obtain the overall permissions for
checkAdminbooleanWhether having ADMINISTRATOR will return all permissions Default: true.

Returns: Readonly<Permissions>Source

rolePermissions

private

rolePermissions(role: Role, checkAdmin: boolean): Readonly<Permissions>

Gets the overall set of permissions for a role in this channel, taking into account channel overwrites. Parameters

NameTypeDescription
roleRoleThe role to obtain the overall permissions for
checkAdminbooleanWhether having ADMINISTRATOR will return all permissions

Returns: Readonly<Permissions>Source

lockPermissions

async

async lockPermissions(): Promise<GuildChannel>

Locks in the permission overwrites from the parent channel. Returns: Promise<GuildChannel>Source

edit

edit(data: ChannelData, reason?: string): Promise<GuildChannel>

Edits the channel. Parameters

NameTypeDescription
dataChannelDataThe new data for the channel
reason?stringReason for editing this channel

Returns: Promise<GuildChannel>

js
// Edit a channel
channel.edit({ name: 'new-channel' })
  .then(console.log)
  .catch(console.error);

Source

setName

setName(name: string, reason?: string): Promise<GuildChannel>

Sets a new name for the guild channel. Parameters

NameTypeDescription
namestringThe new name for the guild channel
reason?stringReason for changing the guild channel's name

Returns: Promise<GuildChannel>

js
// Set a new channel name
channel.setName('not_general')
  .then(newChannel => console.log(`Channel's new name is ${newChannel.name}`))
  .catch(console.error);

Source

setParent

setParent(channel: CategoryChannelResolvable, options?: SetParentOptions): Promise<GuildChannel>

Sets the parent of this channel. Parameters

NameTypeDescription
channelCategoryChannelResolvableThe category channel to set as the parent
options?SetParentOptionsThe options for setting the parent Default: {}.

Returns: Promise<GuildChannel>

js
// 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);

Source

setPosition

setPosition(position: number, options?: SetChannelPositionOptions): Promise<GuildChannel>

Sets a new position for the guild channel. Parameters

NameTypeDescription
positionnumberThe new position for the guild channel
options?SetChannelPositionOptionsOptions for setting position

Returns: Promise<GuildChannel>

js
// Set a new channel position
channel.setPosition(2)
  .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
  .catch(console.error);

Source

clone

clone(options?: GuildChannelCloneOptions): Promise<GuildChannel>

Clones this channel. Parameters

NameTypeDescription
options?GuildChannelCloneOptionsThe options for cloning this channel

Returns: Promise<GuildChannel>Source

equals

equals(channel: 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. Parameters

NameTypeDescription
channelGuildChannelChannel to compare with

Returns: booleanSource

delete

async

async delete(reason?: string): Promise<GuildChannel>

Deletes this channel. Parameters

NameTypeDescription
reason?stringReason for deleting this channel

Returns: Promise<GuildChannel>

js
// Delete the channel
channel.delete('making room for new channels')
  .then(console.log)
  .catch(console.error);

Source

toString

toString(): string

When concatenated with a string, this automatically returns the channel's mention instead of the Channel object. Returns: string

js
// Logs: Hello from <#123456789012345678>!
console.log(`Hello from ${channel}!`);

Source

fetch

fetch(force?: boolean): Promise<Channel>

Fetches this channel. Parameters

NameTypeDescription
force?booleanWhether to skip the cache check and request the API Default: true.

Returns: Promise<Channel>Source

isText

isText(): boolean

Indicates whether this channel is text-based. Returns: booleanSource

isVoice

isVoice(): boolean

Indicates whether this channel is voice-based. Returns: booleanSource

isThread

isThread(): boolean

Indicates whether this channel is a ThreadChannel. Returns: booleanSource

isThreadOnly

isThreadOnly(): boolean

Indicates whether this channel is ThreadOnlyChannel. Returns: booleanSource

isDirectory

isDirectory(): boolean

Indicates whether this channel is a DirectoryChannelReturns: booleanSource

Unofficial software. Not affiliated with or supported by Discord.