GuildChannelManager

export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChannel, GuildChannelResolvable>
export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChannel, GuildChannelResolvable>
Manages API methods for GuildChannels and stores their cache.
Readonly
cache:Collection<Key, Holds>
The cache of items for this manager.
Inherited from DataManager
Readonly
channelCountWithoutThreads:number
The number of channels in this managers cache excluding thread channels that do not count towards a guild's maximum channels restriction.
Readonly
client:Client
The client that instantiated this Manager
Inherited from BaseManager
guild:Guild
The guild this Manager belongs to
Readonly
holds:Constructable<Holds>
The data structure belonging to this manager.
Inherited from DataManager
addFollower(channel, targetChannel, reason?):Promise<Snowflake>
Adds the target channel to a channel's followers.
Returns
Returns created target webhook id.
NameTypeOptionalDescription
channelAnnouncementChannelResolvableNoThe channel to follow
targetChannelTextChannelResolvableNoThe channel where published announcements will be posted at
reasonstringYesReason for creating the webhook
create(options):Promise<MappedGuildChannelTypes[Type]>
Creates a new channel in the guild.
Example
// Create a new text channel
guild.channels.create({ name: 'new-general', reason: 'Needed a cool new channel' })
.then(console.log)
.catch(console.error);
// Create a new text channel
guild.channels.create({ name: 'new-general', reason: 'Needed a cool new channel' })
.then(console.log)
.catch(console.error);
Example
// Create a new channel with permission overwrites
guild.channels.create({
name: 'new-general',
type: ChannelType.GuildVoice,
permissionOverwrites: [
{
id: message.author.id,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
// Create a new channel with permission overwrites
guild.channels.create({
name: 'new-general',
type: ChannelType.GuildVoice,
permissionOverwrites: [
{
id: message.author.id,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
NameConstraintsOptionalDefaultDescription
TypeGuildChannelTypesNoNone
NameTypeOptionalDescription
optionsGuildChannelCreateOptions & { type: Type }NoOptions for creating the new channel
createWebhook(options):Promise<Webhook<WebhookType.Incoming>>
Creates a webhook for the channel.
Returns
Returns the created Webhook
Example
// Create a webhook for the current channel
guild.channels.createWebhook({
channel: '222197033908436994',
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
guild.channels.createWebhook({
channel: '222197033908436994',
name: 'Snek',
avatar: 'https://i.imgur.com/mI8XcpG.jpg',
reason: 'Needed a cool new Webhook'
})
.then(console.log)
.catch(console.error)
NameTypeOptionalDescription
optionsWebhookCreateOptionsNoOptions for creating the webhook
delete(channel, reason?):Promise<void>
Deletes the channel.
Example
// Delete the channel
guild.channels.delete('858850993013260338', 'making room for new channels')
.then(console.log)
.catch(console.error);
// Delete the channel
guild.channels.delete('858850993013260338', 'making room for new channels')
.then(console.log)
.catch(console.error);
NameTypeOptionalDescription
channelGuildChannelResolvableNoThe channel to delete
reasonstringYesReason for deleting this channel
edit(channel, options):Promise<GuildChannel>
Edits the channel.
Example
// Edit a channel
guild.channels.edit('222197033908436994', { name: 'new-channel' })
.then(console.log)
.catch(console.error);
// Edit a channel
guild.channels.edit('222197033908436994', { name: 'new-channel' })
.then(console.log)
.catch(console.error);
NameTypeOptionalDescription
channelGuildChannelResolvableNoThe channel to edit
optionsGuildChannelEditOptionsNoOptions for editing the channel
fetch(id, options?):Promise<GuildBasedChannel | null>
Obtains one or more guild channels from Discord, or the channel cache if they're already available.
Example
// Fetch all channels from the guild (excluding threads)
message.guild.channels.fetch()
.then(channels => console.log(`There are ${channels.size} channels.`))
.catch(console.error);
// Fetch all channels from the guild (excluding threads)
message.guild.channels.fetch()
.then(channels => console.log(`There are ${channels.size} channels.`))
.catch(console.error);
Example
// Fetch a single channel
message.guild.channels.fetch('222197033908436994')
.then(channel => console.log(`The channel name is: ${channel.name}`))
.catch(console.error);
// Fetch a single channel
message.guild.channels.fetch('222197033908436994')
.then(channel => console.log(`The channel name is: ${channel.name}`))
.catch(console.error);
NameTypeOptionalDescription
idSnowflakeNoThe channel's id
optionsBaseFetchOptionsYesAdditional options for this fetch
fetchActiveThreads(cache?):Promise<FetchedThreads>
Obtains all active thread channels in the guild.
Example
// Fetch all threads from the guild
message.guild.channels.fetchActiveThreads()
.then(fetched => console.log(`There are ${fetched.threads.size} threads.`))
.catch(console.error);
// Fetch all threads from the guild
message.guild.channels.fetchActiveThreads()
.then(fetched => console.log(`There are ${fetched.threads.size} threads.`))
.catch(console.error);
NameTypeOptionalDescription
cachebooleanYesWhether to cache the fetched data
Fetches all webhooks for the channel.
Example
// Fetch webhooks
guild.channels.fetchWebhooks('769862166131245066')
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);
// Fetch webhooks
guild.channels.fetchWebhooks('769862166131245066')
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);
NameTypeOptionalDescription
channelGuildChannelResolvableNoThe channel to fetch webhooks for
resolve(channel):GuildChannel | ThreadChannel | null
Resolves a GuildChannelResolvable to a Channel object.
NameTypeOptionalDescription
channelGuildChannelResolvableNoThe GuildChannel resolvable to resolve
resolveId(channel):Snowflake | null
Resolves a GuildChannelResolvable to a channel id.
NameTypeOptionalDescription
channelGuildChannelResolvableNoThe GuildChannel resolvable to resolve
setPosition(channel, position, options?):Promise<GuildChannel>
Sets a new position for the guild channel.
Example
// Set a new channel position
guild.channels.setPosition('222078374472843266', 2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);
// Set a new channel position
guild.channels.setPosition('222078374472843266', 2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);
NameTypeOptionalDescription
channelGuildChannelResolvableNoThe channel to set the position for
positionnumberNoThe new position for the guild channel
optionsSetChannelPositionOptionsYesOptions for setting position
setPositions(channelPositions):Promise<Guild>
Batch-updates the guild's channels' positions. Only one channel's parent can be changed at a time
Example
guild.channels.setPositions([{ channel: channelId, position: newChannelIndex }])
.then(guild => console.log(`Updated channel positions for ${guild}`))
.catch(console.error);
guild.channels.setPositions([{ channel: channelId, position: newChannelIndex }])
.then(guild => console.log(`Updated channel positions for ${guild}`))
.catch(console.error);
NameTypeOptionalDescription
channelPositionsreadonly ChannelPosition[]NoChannel positions to update
valueOf():Collection<Key, Holds>