Guild

export class Guild extends AnonymousGuild
export class Guild extends AnonymousGuild
Represents a guild (or a server) on Discord. It's recommended to see if a guild is available before performing operations or reading data from it. You can check this with available.
Readonly
afkChannel:VoiceChannel | null
AFK voice channel for this guild
afkChannelId:Snowflake | null
The id of the voice channel where AFK members are moved
afkTimeout:number
The time in seconds before a user is counted as "away from keyboard"
applicationId:Snowflake | null
The id of the application that created this guild (if applicable)
approximateMemberCount:number | null
The approximate amount of members the guild has You will need to fetch the guild using fetch if you want to receive this parameter
approximatePresenceCount:number | null
The approximate amount of presences the guild has You will need to fetch the guild using fetch if you want to receive this parameter
autoModerationRules:AutoModerationRuleManager
A manager of the auto moderation rules of this guild.
available:boolean
Whether the guild is available to access. If it is not available, it indicates a server outage
A manager of the bans belonging to this guild
A manager of the channels belonging to this guild
Readonly
client:Client<true>
The client that instantiated this
Inherited from Base
A manager of the application commands belonging to this guild
Readonly
createdAt:Date
The time this guild was created at
Inherited from BaseGuild
Readonly
createdTimestamp:number
The timestamp this guild was created at
Inherited from BaseGuild
defaultMessageNotifications:GuildDefaultMessageNotifications
The default message notification level of the guild
description:string | null
The description of the guild, if any
Inherited from AnonymousGuild
discoverySplash:string | null
The hash of the guild discovery splash image
A manager of the emojis belonging to this guild
explicitContentFilter:GuildExplicitContentFilter
The explicit content filter level of the guild
features:`${GuildFeature}`[]
An array of features available to this guild
Inherited from BaseGuild
icon:string | null
The icon hash of this guild
Inherited from BaseGuild
The guild's id
Inherited from BaseGuild
A manager of the invites of this guild
Readonly
joinedAt:Date
The time the client user joined the guild
joinedTimestamp:number
The timestamp the client user joined the guild at
large:boolean
Whether the guild is "large" (has more than large_threshold members, 50 by default)
Readonly
maximumBitrate:number
The maximum bitrate available for this guild
maximumMembers:number | null
The maximum amount of members the guild can have
maximumPresences:number | null
The maximum amount of presences the guild can have (this is null for all but the largest of guilds) You will need to fetch the guild using fetch if you want to receive this parameter
maxStageVideoChannelUsers:number | null
The maximum amount of users allowed in a stage video channel.
maxVideoChannelUsers:number | null
The maximum amount of users allowed in a video channel.
memberCount:number
The full amount of members in this guild
A manager of the members belonging to this guild
mfaLevel:GuildMFALevel
The required MFA level for this guild
name:string
The name of this guild
Inherited from BaseGuild
Readonly
nameAcronym:string
The acronym that shows up in place of a guild icon
Inherited from BaseGuild
nsfwLevel:GuildNSFWLevel
The NSFW level of this guild
Inherited from AnonymousGuild
ownerId:Snowflake
The user id of this guild's owner
Readonly
partnered:boolean
Whether this guild is partnered
Inherited from BaseGuild
preferredLocale:Locale
The preferred locale of the guild, defaults to en-US
premiumProgressBarEnabled:boolean
Whether this guild has its premium (boost) progress bar enabled
premiumSubscriptionCount:number | null
The total number of boosts for this server
Inherited from AnonymousGuild
premiumTier:GuildPremiumTier
The premium tier of this guild
presences:PresenceManager
A manager of the presences belonging to this guild
Readonly
publicUpdatesChannel:TextChannel | null
Public updates channel for this guild
publicUpdatesChannelId:Snowflake | null
The community updates channel's id for the guild
A manager of the roles belonging to this guild
Readonly
rulesChannel:TextChannel | null
Rules channel for this guild
rulesChannelId:Snowflake | null
The rules channel's id for the guild
Readonly
safetyAlertsChannel:TextChannel | null
Safety alerts channel for this guild
safetyAlertsChannelId:Snowflake | null
The safety alerts channel's id for the guild
A manager of the scheduled events of this guild
Readonly
The Shard this Guild belongs to.
shardId:number
The id of the shard this Guild belongs to.
splash:string | null
The hash of the guild invite splash image
Inherited from AnonymousGuild
stageInstances:StageInstanceManager
A manager of the stage instances of this guild
A manager of the stickers belonging to this guild
Readonly
systemChannel:TextChannel | null
System channel for this guild
The value set for the guild's system channel flags
systemChannelId:Snowflake | null
The system channel's id
vanityURLCode:string | null
The vanity invite code of the guild, if any
Inherited from AnonymousGuild
vanityURLUses:number | null
The use count of the vanity URL code of the guild, if any You will need to fetch this parameter using fetchVanityData if you want to receive it
verificationLevel:GuildVerificationLevel
The verification level of the guild
Inherited from AnonymousGuild
Readonly
verified:boolean
Whether this guild is verified
Inherited from BaseGuild
Readonly
The voice state adapter for this guild that can be used with @discordjs/voice to play audio in voice and stage channels.
voiceStates:VoiceStateManager
A manager of the voice states of this guild
Widget channel for this guild
widgetChannelId:Snowflake | null
The widget channel's id, if enabled
widgetEnabled:boolean | null
Whether widget images are enabled on this guild
bannerURL(options?):string | null
The URL to this guild's banner.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
Inherited from AnonymousGuild
createTemplate(name, description?):Promise<GuildTemplate>
Creates a template for the guild.
NameTypeOptionalDescription
namestringNoThe name for the template
descriptionstringYesThe description for the template
delete():Promise<Guild>
Deletes the guild.
Example
// Delete a guild
guild.delete()
.then(guild => console.log(`Deleted the guild ${guild}`))
.catch(console.error);
// Delete a guild
guild.delete()
.then(guild => console.log(`Deleted the guild ${guild}`))
.catch(console.error);
disableInvites(disabled?):Promise<Guild>
Sets whether this guild's invites are disabled.
NameTypeOptionalDescription
disabledbooleanYesWhether the invites are disabled
discoverySplashURL(options?):string | null
The URL to this guild's discovery splash image.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
edit(options):Promise<Guild>
Updates the guild with new information - e.g. a new name.
Example
// Set the guild name
guild.edit({
name: 'Discord Guild',
})
.then(updated => console.log(`New guild name ${updated}`))
.catch(console.error);
// Set the guild name
guild.edit({
name: 'Discord Guild',
})
.then(updated => console.log(`New guild name ${updated}`))
.catch(console.error);
NameTypeOptionalDescription
optionsGuildEditOptionsNoThe options to provide
editOnboarding(options):Promise<GuildOnboarding>
Edits the guild onboarding data for this guild.
NameTypeOptionalDescription
optionsGuildOnboardingEditOptionsNoThe options to provide
editWelcomeScreen(options):Promise<WelcomeScreen>
Updates the guild's welcome screen
Example
guild.editWelcomeScreen({
description: 'Hello World',
enabled: true,
welcomeChannels: [
{
description: 'foobar',
channel: '222197033908436994',
}
],
})
guild.editWelcomeScreen({
description: 'Hello World',
enabled: true,
welcomeChannels: [
{
description: 'foobar',
channel: '222197033908436994',
}
],
})
NameTypeOptionalDescription
optionsWelcomeScreenEditOptionsNoThe options to provide
equals(guild):boolean
Whether this guild equals another guild. It compares all properties, so for most operations it is advisable to just compare guild.id === guild2.id as it is much faster and is often what most users need.
NameTypeOptionalDescription
guildGuildNoThe guild to compare with
fetch():Promise<Guild>
Fetches this guild.
Inherited from BaseGuild
fetchAuditLogs(options?):Promise<GuildAuditLogs<Event>>
Fetches audit logs for this guild.
Example
// Output audit log entries
guild.fetchAuditLogs()
.then(audit => console.log(audit.entries.first()))
.catch(console.error);
// Output audit log entries
guild.fetchAuditLogs()
.then(audit => console.log(audit.entries.first()))
.catch(console.error);
NameTypeOptionalDescription
optionsGuildAuditLogsFetchOptions<Event>YesOptions for fetching audit logs
fetchIntegrations():Promise<Collection<Snowflake | string, Integration>>
Fetches a collection of integrations to this guild. Resolves with a collection mapping integrations by their ids.
Example
// Fetch integrations
guild.fetchIntegrations()
.then(integrations => console.log(`Fetched ${integrations.size} integrations`))
.catch(console.error);
// Fetch integrations
guild.fetchIntegrations()
.then(integrations => console.log(`Fetched ${integrations.size} integrations`))
.catch(console.error);
fetchOnboarding():Promise<GuildOnboarding>
Fetches the guild onboarding data for this guild.
fetchOwner(options?):Promise<GuildMember>
Fetches the owner of the guild. If the member object isn't needed, use ownerId instead.
NameTypeOptionalDescription
optionsBaseFetchOptionsYesThe options for fetching the member
fetchPreview():Promise<GuildPreview>
Obtains a guild preview for this guild from Discord.
fetchTemplates():Promise<Collection<GuildTemplate['code'], GuildTemplate>>
Fetches a collection of templates from this guild. Resolves with a collection mapping templates by their codes.
fetchVanityData():Promise<Vanity>
Fetches the vanity URL invite object to this guild. Resolves with an object containing the vanity URL invite code and the use count
Example
// Fetch invite data
guild.fetchVanityData()
.then(res => {
console.log(`Vanity URL: https://discord.gg/${res.code} with ${res.uses} uses`);
})
.catch(console.error);
// Fetch invite data
guild.fetchVanityData()
.then(res => {
console.log(`Vanity URL: https://discord.gg/${res.code} with ${res.uses} uses`);
})
.catch(console.error);
Fetches all webhooks for the guild.
Example
// Fetch webhooks
guild.fetchWebhooks()
.then(webhooks => console.log(`Fetched ${webhooks.size} webhooks`))
.catch(console.error);
// Fetch webhooks
guild.fetchWebhooks()
.then(webhooks => console.log(`Fetched ${webhooks.size} webhooks`))
.catch(console.error);
fetchWelcomeScreen():Promise<WelcomeScreen>
Fetches the welcome screen for this guild.
fetchWidget():Promise<Widget>
Fetches the guild widget data, requires the widget to be enabled.
Example
// Fetches the guild widget data
guild.fetchWidget()
.then(widget => console.log(`The widget shows ${widget.channels.size} channels`))
.catch(console.error);
// Fetches the guild widget data
guild.fetchWidget()
.then(widget => console.log(`The widget shows ${widget.channels.size} channels`))
.catch(console.error);
fetchWidgetSettings():Promise<GuildWidgetSettings>
Fetches the guild widget settings.
Example
// Fetches the guild widget settings
guild.fetchWidgetSettings()
.then(widget => console.log(`The widget is ${widget.enabled ? 'enabled' : 'disabled'}`))
.catch(console.error);
// Fetches the guild widget settings
guild.fetchWidgetSettings()
.then(widget => console.log(`The widget is ${widget.enabled ? 'enabled' : 'disabled'}`))
.catch(console.error);
iconURL(options?):string | null
The URL to this guild's icon.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
Inherited from BaseGuild
leave():Promise<Guild>
Leaves the guild.
Example
// Leave a guild
guild.leave()
.then(guild => console.log(`Left the guild: ${guild.name}`))
.catch(console.error);
// Leave a guild
guild.leave()
.then(guild => console.log(`Left the guild: ${guild.name}`))
.catch(console.error);
setAFKChannel(afkChannel, reason?):Promise<Guild>
Edits the AFK channel of the guild.
Example
// Edit the guild AFK channel
guild.setAFKChannel(channel)
.then(updated => console.log(`Updated guild AFK channel to ${guild.afkChannel.name}`))
.catch(console.error);
// Edit the guild AFK channel
guild.setAFKChannel(channel)
.then(updated => console.log(`Updated guild AFK channel to ${guild.afkChannel.name}`))
.catch(console.error);
NameTypeOptionalDescription
afkChannelVoiceChannelResolvable | nullNoThe new AFK channel
reasonstringYesReason for changing the guild's AFK channel
setAFKTimeout(afkTimeout, reason?):Promise<Guild>
Edits the AFK timeout of the guild.
Example
// Edit the guild AFK channel
guild.setAFKTimeout(60)
.then(updated => console.log(`Updated guild AFK timeout to ${guild.afkTimeout}`))
.catch(console.error);
// Edit the guild AFK channel
guild.setAFKTimeout(60)
.then(updated => console.log(`Updated guild AFK timeout to ${guild.afkTimeout}`))
.catch(console.error);
NameTypeOptionalDescription
afkTimeoutnumberNoThe time in seconds that a user must be idle to be considered AFK
reasonstringYesReason for changing the guild's AFK timeout
setBanner(banner, reason?):Promise<Guild>
Sets a new guild banner.
Example
guild.setBanner('./banner.png')
.then(updated => console.log('Updated the guild banner'))
.catch(console.error);
guild.setBanner('./banner.png')
.then(updated => console.log('Updated the guild banner'))
.catch(console.error);
NameTypeOptionalDescription
bannerBufferResolvable | Base64Resolvable | nullNoThe new banner of the guild
reasonstringYesReason for changing the guild's banner
setDefaultMessageNotifications(defaultMessageNotifications, reason?):Promise<Guild>
Edits the setting of the default message notifications of the guild.
NameTypeOptionalDescription
defaultMessageNotificationsGuildDefaultMessageNotifications | nullNoThe new default message notification level of the guild
reasonstringYesReason for changing the setting of the default message notifications
setDiscoverySplash(discoverySplash, reason?):Promise<Guild>
Sets a new guild discovery splash image.
Example
// Edit the guild discovery splash
guild.setDiscoverySplash('./discoverysplash.png')
.then(updated => console.log('Updated the guild discovery splash'))
.catch(console.error);
// Edit the guild discovery splash
guild.setDiscoverySplash('./discoverysplash.png')
.then(updated => console.log('Updated the guild discovery splash'))
.catch(console.error);
NameTypeOptionalDescription
discoverySplashBufferResolvable | Base64Resolvable | nullNoThe new discovery splash image of the guild
reasonstringYesReason for changing the guild's discovery splash image
setExplicitContentFilter(explicitContentFilter, reason?):Promise<Guild>
Edits the level of the explicit content filter.
NameTypeOptionalDescription
explicitContentFilterGuildExplicitContentFilter | nullNoThe new level of the explicit content filter
reasonstringYesReason for changing the level of the guild's explicit content filter
setIcon(icon, reason?):Promise<Guild>
Sets a new guild icon.
Example
// Edit the guild icon
guild.setIcon('./icon.png')
.then(updated => console.log('Updated the guild icon'))
.catch(console.error);
// Edit the guild icon
guild.setIcon('./icon.png')
.then(updated => console.log('Updated the guild icon'))
.catch(console.error);
NameTypeOptionalDescription
iconBufferResolvable | Base64Resolvable | nullNoThe new icon of the guild
reasonstringYesReason for changing the guild's icon
setMFALevel(level, reason?):Promise<Guild>
Sets the guild's MFA level An elevated MFA level requires guild moderators to have 2FA enabled.
Example
// Set the MFA level of the guild to Elevated
guild.setMFALevel(GuildMFALevel.Elevated)
.then(guild => console.log("Set guild's MFA level to Elevated"))
.catch(console.error);
// Set the MFA level of the guild to Elevated
guild.setMFALevel(GuildMFALevel.Elevated)
.then(guild => console.log("Set guild's MFA level to Elevated"))
.catch(console.error);
NameTypeOptionalDescription
levelGuildMFALevelNoThe MFA level
reasonstringYesReason for changing the guild's MFA level
setName(name, reason?):Promise<Guild>
Edits the name of the guild.
Example
// Edit the guild name
guild.setName('Discord Guild')
.then(updated => console.log(`Updated guild name to ${updated.name}`))
.catch(console.error);
// Edit the guild name
guild.setName('Discord Guild')
.then(updated => console.log(`Updated guild name to ${updated.name}`))
.catch(console.error);
NameTypeOptionalDescription
namestringNoThe new name of the guild
reasonstringYesReason for changing the guild's name
setOwner(owner, reason?):Promise<Guild>
Sets a new owner of the guild.
Example
// Edit the guild owner
guild.setOwner(guild.members.cache.first())
.then(guild => guild.fetchOwner())
.then(owner => console.log(`Updated the guild owner to ${owner.displayName}`))
.catch(console.error);
// Edit the guild owner
guild.setOwner(guild.members.cache.first())
.then(guild => guild.fetchOwner())
.then(owner => console.log(`Updated the guild owner to ${owner.displayName}`))
.catch(console.error);
NameTypeOptionalDescription
ownerGuildMemberResolvableNoThe new owner of the guild
reasonstringYesReason for setting the new owner
setPreferredLocale(preferredLocale, reason?):Promise<Guild>
Edits the preferred locale of the guild.
Example
// Edit the guild preferred locale
guild.setPreferredLocale('en-US')
.then(updated => console.log(`Updated guild preferred locale to ${guild.preferredLocale}`))
.catch(console.error);
// Edit the guild preferred locale
guild.setPreferredLocale('en-US')
.then(updated => console.log(`Updated guild preferred locale to ${guild.preferredLocale}`))
.catch(console.error);
NameTypeOptionalDescription
preferredLocaleLocale | nullNoThe new preferred locale of the guild
reasonstringYesReason for changing the guild's preferred locale
setPremiumProgressBarEnabled(enabled?, reason?):Promise<Guild>
Edits the enabled state of the guild's premium progress bar
NameTypeOptionalDescription
enabledbooleanYesThe new enabled state of the guild's premium progress bar
reasonstringYesReason for changing the state of the guild's premium progress bar
setPublicUpdatesChannel(publicUpdatesChannel, reason?):Promise<Guild>
Edits the community updates channel of the guild.
Example
// Edit the guild community updates channel
guild.setPublicUpdatesChannel(channel)
.then(updated => console.log(`Updated guild community updates channel to ${guild.publicUpdatesChannel.name}`))
.catch(console.error);
// Edit the guild community updates channel
guild.setPublicUpdatesChannel(channel)
.then(updated => console.log(`Updated guild community updates channel to ${guild.publicUpdatesChannel.name}`))
.catch(console.error);
NameTypeOptionalDescription
publicUpdatesChannelTextChannelResolvable | nullNoThe new community updates channel
reasonstringYesReason for changing the guild's community updates channel
setRulesChannel(rulesChannel, reason?):Promise<Guild>
Edits the rules channel of the guild.
Example
// Edit the guild rules channel
guild.setRulesChannel(channel)
.then(updated => console.log(`Updated guild rules channel to ${guild.rulesChannel.name}`))
.catch(console.error);
// Edit the guild rules channel
guild.setRulesChannel(channel)
.then(updated => console.log(`Updated guild rules channel to ${guild.rulesChannel.name}`))
.catch(console.error);
NameTypeOptionalDescription
rulesChannelTextChannelResolvable | nullNoThe new rules channel
reasonstringYesReason for changing the guild's rules channel
setSafetyAlertsChannel(safetyAlertsChannel, reason?):Promise<Guild>
Edits the safety alerts channel of the guild.
Example
// Edit the guild safety alerts channel
guild.setSafetyAlertsChannel(channel)
.then(updated => console.log(`Updated guild safety alerts channel to ${updated.safetyAlertsChannel.name}`))
.catch(console.error);
// Edit the guild safety alerts channel
guild.setSafetyAlertsChannel(channel)
.then(updated => console.log(`Updated guild safety alerts channel to ${updated.safetyAlertsChannel.name}`))
.catch(console.error);
NameTypeOptionalDescription
safetyAlertsChannelTextChannelResolvable | nullNoThe new safety alerts channel
reasonstringYesReason for changing the guild's safety alerts channel
setSplash(splash, reason?):Promise<Guild>
Sets a new guild invite splash image.
Example
// Edit the guild splash
guild.setSplash('./splash.png')
.then(updated => console.log('Updated the guild splash'))
.catch(console.error);
// Edit the guild splash
guild.setSplash('./splash.png')
.then(updated => console.log('Updated the guild splash'))
.catch(console.error);
NameTypeOptionalDescription
splashBufferResolvable | Base64Resolvable | nullNoThe new invite splash image of the guild
reasonstringYesReason for changing the guild's invite splash image
setSystemChannel(systemChannel, reason?):Promise<Guild>
Edits the system channel of the guild.
Example
// Edit the guild system channel
guild.setSystemChannel(channel)
.then(updated => console.log(`Updated guild system channel to ${guild.systemChannel.name}`))
.catch(console.error);
// Edit the guild system channel
guild.setSystemChannel(channel)
.then(updated => console.log(`Updated guild system channel to ${guild.systemChannel.name}`))
.catch(console.error);
NameTypeOptionalDescription
systemChannelTextChannelResolvable | nullNoThe new system channel
reasonstringYesReason for changing the guild's system channel
setSystemChannelFlags(systemChannelFlags, reason?):Promise<Guild>
Edits the flags of the default message notifications of the guild.
NameTypeOptionalDescription
systemChannelFlagsSystemChannelFlagsResolvableNoThe new flags for the default message notifications
reasonstringYesReason for changing the flags of the default message notifications
setVerificationLevel(verificationLevel, reason?):Promise<Guild>
Edits the verification level of the guild.
Example
// Edit the guild verification level
guild.setVerificationLevel(1)
.then(updated => console.log(`Updated guild verification level to ${guild.verificationLevel}`))
.catch(console.error);
// Edit the guild verification level
guild.setVerificationLevel(1)
.then(updated => console.log(`Updated guild verification level to ${guild.verificationLevel}`))
.catch(console.error);
NameTypeOptionalDescription
verificationLevelGuildVerificationLevel | nullNoThe new verification level of the guild
reasonstringYesReason for changing the guild's verification level
setWidgetSettings(settings, reason?):Promise<Guild>
Edits the guild's widget settings.
NameTypeOptionalDescription
settingsGuildWidgetSettingsDataNoThe widget settings for the guild
reasonstringYesReason for changing the guild's widget settings
splashURL(options?):string | null
The URL to this guild's invite splash image.
Returns
NameTypeOptionalDescription
optionsImageURLOptionsYesOptions for the image URL
Inherited from AnonymousGuild
toJSON():unknown
toString():string
When concatenated with a string, this automatically returns the guild's name instead of the Guild object.
Inherited from BaseGuild
valueOf():string
widgetImageURL(style?):string
Returns a URL for the PNG widget of the guild.
NameTypeOptionalDescription
styleGuildWidgetStyleYesThe style for the widget image