export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChannel, GuildChannelResolvable>
Manages API methods for GuildChannels and stores their cache.
Collection<Snowflake, (GuildChannel|ThreadChannel)> cache :
The cache of this Manager
readonlynumber channelCountWithoutThreads :
The number of channels in this managers cache excluding thread channels that do not count towards a guild's maximum channels restriction.
readonlyClient client :
The client that instantiated this Manager
Guild guild :
The guild this Manager belongs to
readonlyConstructable<Holds> holds :
The data structure belonging to this manager.
Inherited from: DataManager
Adds the target channel to a channel's followers.
Returns: Returns created target webhook id.
createType extends GuildChannelTypes
>(options: GuildChannelCreateOptions & { type: Type }) : Promise<MappedGuildChannelTypes[Type]> <
Type extends GuildChannelTypes
Creates a new channel in the guild.
// 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 channel with permission overwrites
guild.channels.create({
name: 'new-general',
type: ChannelType.GuildVoice,
permissionOverwrites: [
{
id: message.author.id,
deny: [PermissionFlagsBits.ViewChannel],
},
],
})
createWebhookoptions: WebhookCreateOptions) : Promise<Webhook> (
Creates a webhook for the channel.
// 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)
Returns: Returns the created Webhook
deletechannel: GuildChannelResolvablereason?: string) : Promise<void> (
Deletes the channel.
// Delete the channel
guild.channels.delete('858850993013260338', 'making room for new channels')
.then(console.log)
.catch(console.error);
editchannel: GuildChannelResolvableoptions: GuildChannelEditOptions) : Promise<GuildChannel> (
Edits the channel.
// Edit a channel
guild.channels.edit('222197033908436994', { name: 'new-channel' })
.then(console.log)
.catch(console.error);
fetchid: Snowflakeoptions?: BaseFetchOptions) : Promise<GuildBasedChannel | null> (
Obtains one or more guild channels from Discord, or the channel cache if they're already available.
// 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 a single channel
message.guild.channels.fetch('222197033908436994')
.then(channel => console.log(`The channel name is: ${channel.name}`))
.catch(console.error);
fetchActiveThreadscache?: boolean) : Promise<FetchedThreads> (
Obtains all active thread channels in the guild.
// Fetch all threads from the guild
message.guild.channels.fetchActiveThreads()
.then(fetched => console.log(`There are ${fetched.threads.size} threads.`))
.catch(console.error);
fetchWebhookschannel: GuildChannelResolvable) : Promise<Collection<Snowflake, Webhook>> (
Fetches all webhooks for the channel.
// Fetch webhooks
guild.channels.fetchWebhooks('769862166131245066')
.then(hooks => console.log(`This channel has ${hooks.size} hooks`))
.catch(console.error);
resolvechannel: GuildChannelResolvable) : GuildChannel | ThreadChannel (
Resolves a GuildChannelResolvable to a Channel object.
resolveIdchannel: GuildChannelResolvable) : Snowflake (
Resolves a GuildChannelResolvable to a channel id.
setPosition) : Promise<GuildChannel> (
Sets a new position for the guild channel.
// Set a new channel position
guild.channels.setPosition('222078374472843266', 2)
.then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
.catch(console.error);
setPositionschannelPositions: readonly ChannelPosition[]) : Promise<Guild> (
Batch-updates the guild's channels' positions. Only one channel's parent can be changed at a time
guild.channels.setPositions([{ channel: channelId, position: newChannelIndex }])
.then(guild => console.log(`Updated channel positions for ${guild}`))
.catch(console.error);
valueOfCollection<Key, Holds> () :
Inherited from: DataManager