class Guild
extends
AnonymousGuildexport class Guild extends AnonymousGuildRepresents 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.
readonlyafkChannel : VoiceChannel | null
AFK voice channel for this guild
afkTimeout : number
The time in seconds before a user is counted as "away from keyboard"
The approximate amount of members the guild has You will need to fetch the guild using fetch if you want to receive this parameter
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
bans : GuildBanManager
A manager of the bans belonging to this guild
channels : GuildChannelManager
A manager of the channels belonging to this guild
commands : GuildApplicationCommandManager
A manager of the application commands belonging to this guild
defaultMessageNotifications : GuildDefaultMessageNotifications
The default message notification level of the guild
emojis : GuildEmojiManager
A manager of the emojis belonging to this guild
explicitContentFilter : GuildExplicitContentFilter
The explicit content filter level of the guild
incidentsData : IncidentActions | null
The incidents data of this guild. You will need to fetch the guild using fetch if you want to receive this property.
invites : GuildInviteManager
A manager of the invites of this guild
readonlyjoinedAt : 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)
readonlymaximumBitrate : number
The maximum bitrate available for this guild
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
The maximum amount of users allowed in a stage video channel.
memberCount : number
The full amount of members in this guild
members : GuildMemberManager
A manager of the members belonging to this guild
mfaLevel : GuildMFALevel
The required MFA level for this guild
readonlynameAcronym : string
The acronym that shows up in place of a guild icon
Inherited from: BaseGuild
ownerId : Snowflake
The user id of this guild's owner
preferredLocale : Locale
The preferred locale of the guild, defaults to en-US
premiumProgressBarEnabled : boolean
Whether this guild has its premium (boost) progress bar enabled
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
readonlypublicUpdatesChannel : TextChannel | null
Public updates channel for this guild
roles : RoleManager
A manager of the roles belonging to this guild
readonlyrulesChannel : TextChannel | null
Rules channel for this guild
readonlysafetyAlertsChannel : TextChannel | null
Safety alerts channel for this guild
scheduledEvents : GuildScheduledEventManager
A manager of the scheduled events of this guild
readonlyshard : WebSocketShard
The Shard this Guild belongs to.
shardId : number
The id of the shard this Guild belongs to.
soundboardSounds : GuildSoundboardSoundManager
A manager of the soundboard sounds of this guild.
stageInstances : StageInstanceManager
A manager of the stage instances of this guild
stickers : GuildStickerManager
A manager of the stickers belonging to this guild
readonlysystemChannel : TextChannel | null
System channel for this guild
systemChannelFlags : Readonly<SystemChannelFlagsBitField>
The value set for the guild's system channel flags
The vanity invite code of the guild, if any
Inherited from: AnonymousGuild
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
readonlyvoiceAdapterCreator : InternalDiscordGatewayAdapterCreator
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
readonlywidgetChannel : TextChannel | NewsChannel | VoiceBasedChannel | ForumChannel | MediaChannel | null
Widget channel for this guild
bannerURL(options?: ImageURLOptions) : string | null
The URL to this guild's banner.
Inherited from: AnonymousGuild
createTemplate() : Promise<GuildTemplate>
Creates a template for the guild.
Deletes the guild.
// Delete a guild
guild.delete()
.then(guild => console.log(`Deleted the guild ${guild}`))
.catch(console.error); discoverySplashURL(options?: ImageURLOptions) : string | null
The URL to this guild's discovery splash image.
edit(options: GuildEditOptions) : Promise<Guild>
Updates the guild with new information - e.g. a new name.
// Set the guild name
guild.edit({
name: 'Discord Guild',
})
.then(updated => console.log(`New guild name ${updated}`))
.catch(console.error); editOnboarding(options: GuildOnboardingEditOptions) : Promise<GuildOnboarding>
Edits the guild onboarding data for this guild.
editWelcomeScreen(options: WelcomeScreenEditOptions) : Promise<WelcomeScreen>
Updates the guild's welcome screen
guild.editWelcomeScreen({
description: 'Hello World',
enabled: true,
welcomeChannels: [
{
description: 'foobar',
channel: '222197033908436994',
}
],
})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.
fetchAuditLogs<Event? extends GuildAuditLogsResolvable = AuditLogEvent
>(options?: GuildAuditLogsFetchOptions<Event>) : Promise<GuildAuditLogs<Event extends null ? AuditLogEvent : Event>>
Event? extends GuildAuditLogsResolvable = AuditLogEvent
Fetches audit logs for this guild.
// Output audit log entries
guild.fetchAuditLogs()
.then(audit => console.log(audit.entries.first()))
.catch(console.error);fetchIntegrations() : Promise<Collection<Snowflake | string, Integration>>
Fetches a collection of integrations to this guild. Resolves with a collection mapping integrations by their ids.
// 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?: BaseFetchOptions) : Promise<GuildMember>
Fetches the owner of the guild. If the member object isn't needed, use ownerId instead.
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.
Fetches the vanity URL invite object to this guild. Resolves with an object containing the vanity URL invite code and the use count
// Fetch invite data
guild.fetchVanityData()
.then(res => {
console.log(`Vanity URL: https://discord.gg/${res.code} with ${res.uses} uses`);
})
.catch(console.error);fetchWebhooks() : Promise<Collection<Snowflake, Webhook<WebhookType.ChannelFollower | WebhookType.Incoming>>>
Fetches all webhooks for the guild.
// 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.
Fetches the guild widget data, requires the widget to be enabled.
// 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.
// Fetches the guild widget settings
guild.fetchWidgetSettings()
.then(widget => console.log(`The widget is ${widget.enabled ? 'enabled' : 'disabled'}`))
.catch(console.error); iconURL(options?: ImageURLOptions) : string | null
The URL to this guild's icon.
Inherited from: BaseGuild
Leaves the guild.
// Leave a guild
guild.leave()
.then(guild => console.log(`Left the guild: ${guild.name}`))
.catch(console.error); setAFKChannel(afkChannel: VoiceChannelResolvable | nullreason?: string) : Promise<Guild>
Edits the AFK channel of the guild.
// Edit the guild AFK channel
guild.setAFKChannel(channel)
.then(updated => console.log(`Updated guild AFK channel to ${guild.afkChannel.name}`))
.catch(console.error);Edits the AFK timeout of the guild.
// Edit the guild AFK channel
guild.setAFKTimeout(60)
.then(updated => console.log(`Updated guild AFK timeout to ${guild.afkTimeout}`))
.catch(console.error); setBanner(banner: BufferResolvable | Base64Resolvable | nullreason?: string) : Promise<Guild>
Sets a new guild banner.
guild.setBanner('./banner.png')
.then(updated => console.log('Updated the guild banner'))
.catch(console.error); setDefaultMessageNotifications(defaultMessageNotifications: GuildDefaultMessageNotifications | nullreason?: string) : Promise<Guild>
Edits the setting of the default message notifications of the guild.
setDiscoverySplash(discoverySplash: BufferResolvable | Base64Resolvable | nullreason?: string) : Promise<Guild>
Sets a new guild discovery splash image.
// Edit the guild discovery splash
guild.setDiscoverySplash('./discoverysplash.png')
.then(updated => console.log('Updated the guild discovery splash'))
.catch(console.error); setExplicitContentFilter(explicitContentFilter: GuildExplicitContentFilter | nullreason?: string) : Promise<Guild>
Edits the level of the explicit content filter.
setIcon(icon: BufferResolvable | Base64Resolvable | nullreason?: string) : Promise<Guild>
Sets a new guild icon.
// Edit the guild icon
guild.setIcon('./icon.png')
.then(updated => console.log('Updated the guild icon'))
.catch(console.error); setIncidentActions(incidentActions: IncidentActionsEditOptions) : Promise<IncidentActions>
Sets the incident actions for a guild.
setMFALevel(level: GuildMFALevelreason?: string) : Promise<Guild>
Sets the guild's MFA level An elevated MFA level requires guild moderators to have 2FA enabled.
// 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);Edits the name of the guild.
// Edit the guild name
guild.setName('Discord Guild')
.then(updated => console.log(`Updated guild name to ${updated.name}`))
.catch(console.error); setOwner(owner: GuildMemberResolvablereason?: string) : Promise<Guild>
Sets a new owner of the guild.
// 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);Edits the preferred locale of the guild.
// Edit the guild preferred locale
guild.setPreferredLocale('en-US')
.then(updated => console.log(`Updated guild preferred locale to ${guild.preferredLocale}`))
.catch(console.error);Edits the enabled state of the guild's premium progress bar
setPublicUpdatesChannel(publicUpdatesChannel: TextChannelResolvable | nullreason?: string) : Promise<Guild>
Edits the community updates channel of the guild.
// 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); setRulesChannel(rulesChannel: TextChannelResolvable | nullreason?: string) : Promise<Guild>
Edits the rules channel of the guild.
// Edit the guild rules channel
guild.setRulesChannel(channel)
.then(updated => console.log(`Updated guild rules channel to ${guild.rulesChannel.name}`))
.catch(console.error); setSafetyAlertsChannel(safetyAlertsChannel: TextChannelResolvable | nullreason?: string) : Promise<Guild>
Edits the safety alerts channel of the guild.
// 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); setSplash(splash: BufferResolvable | Base64Resolvable | nullreason?: string) : Promise<Guild>
Sets a new guild invite splash image.
// Edit the guild splash
guild.setSplash('./splash.png')
.then(updated => console.log('Updated the guild splash'))
.catch(console.error); setSystemChannel(systemChannel: TextChannelResolvable | nullreason?: string) : Promise<Guild>
Edits the system channel of the guild.
// Edit the guild system channel
guild.setSystemChannel(channel)
.then(updated => console.log(`Updated guild system channel to ${guild.systemChannel.name}`))
.catch(console.error); setSystemChannelFlags(systemChannelFlags: SystemChannelFlagsResolvablereason?: string) : Promise<Guild>
Edits the flags of the default message notifications of the guild.
setVerificationLevel(verificationLevel: GuildVerificationLevel | nullreason?: string) : Promise<Guild>
Edits the verification level of the guild.
// Edit the guild verification level
guild.setVerificationLevel(1)
.then(updated => console.log(`Updated guild verification level to ${guild.verificationLevel}`))
.catch(console.error); setWidgetSettings(settings: GuildWidgetSettingsDatareason?: string) : Promise<Guild>
Edits the guild's widget settings.
splashURL(options?: ImageURLOptions) : string | null
The URL to this guild's invite splash image.
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
widgetImageURL(style?: GuildWidgetStyle) : string
Returns a URL for the PNG widget of the guild.