export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChannel, GuildChannelResolvable>Manages API methods for GuildChannels and stores their cache.
readonlycache : Collection<Key, Holds>
The cache of items for this manager.
Inherited from: DataManager
readonlychannelCountWithoutThreads : number
The number of channels in this managers cache excluding thread channels that do not count towards a guild's maximum channels restriction.
guild : Guild
The guild this Manager belongs to
readonlyholds : Constructable<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.
create<Type 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],
},
],
}) createWebhook(options: WebhookCreateOptions) : Promise<Webhook<WebhookType.Incoming>>
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
delete(channel: 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); edit(channel: GuildChannelResolvableoptions: GuildChannelEditOptions) : Promise<GuildChannel>
Edits the channel.
// Edit a channel
guild.channels.edit('222197033908436994', { name: 'new-channel' })
.then(console.log)
.catch(console.error); fetch(id: 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); fetchActiveThreads(cache?: 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); fetchWebhooks(channel: GuildChannelResolvable) : Promise<Collection<Snowflake, Webhook<WebhookType.ChannelFollower | WebhookType.Incoming>>>
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); resolve(channel: GuildChannelResolvable) : GuildChannel | ThreadChannel | null
Resolves a GuildChannelResolvable to a Channel object.
resolveId(channel: GuildChannelResolvable) : Snowflake | null
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); setPositions(channelPositions: 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);valueOf() : Collection<Key, Holds>
Inherited from: DataManager