Preview deployment

class Guild

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

The hash of the guild banner

Inherited from: AnonymousGuild

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

roles : RoleManager

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

scheduledEvents : GuildScheduledEventManager

A manager of the scheduled events of this guild

readonly
shard : WebSocketShard

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

systemChannelFlags : Readonly<SystemChannelFlagsBitField>

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
voiceAdapterCreator : 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

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?: ImageURLOptions
) : string | null

The URL to this guild's banner.

Inherited from: AnonymousGuild

createTemplate(
name: string
description?: string
) : Promise<GuildTemplate>

Creates a template for the guild.

delete() : Promise<Guild>

Deletes the guild.

Examples:
// Delete a guild
guild.delete()
  .then(guild => console.log(`Deleted the guild ${guild}`))
  .catch(console.error);

disableInvites(
disabled?: boolean
) : Promise<Guild>

Sets whether this guild's invites are disabled.

discoverySplashURL(
options?: ImageURLOptions
) : string | null

The URL to this guild's discovery splash image.

edit() : Promise<Guild>

Updates the guild with new information - e.g. a new name.

Examples:
// Set the guild name
guild.edit({
  name: 'Discord Guild',
})
  .then(updated => console.log(`New guild name ${updated}`))
  .catch(console.error);

Edits the guild onboarding data for this guild.

editWelcomeScreen() : Promise<WelcomeScreen>

Updates the guild's welcome screen

Examples:
guild.editWelcomeScreen({
  description: 'Hello World',
  enabled: true,
  welcomeChannels: [
    {
      description: 'foobar',
      channel: '222197033908436994',
    }
  ],
})

equals(
guild: 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.

fetch() : Promise<Guild>

Fetches this guild.

Inherited from: BaseGuild

fetchAuditLogs<>() : Promise<GuildAuditLogs<Event>>

Fetches audit logs for this guild.

Examples:
// 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.

Examples:
// 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() : 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.

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

Examples:
// 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.

Examples:
// 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.

Examples:
// 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.

Examples:
// 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

leave() : Promise<Guild>

Leaves the guild.

Examples:
// Leave a guild
guild.leave()
  .then(guild => console.log(`Left the guild: ${guild.name}`))
  .catch(console.error);

setAFKChannel(
reason?: string
) : Promise<Guild>

Edits the AFK channel of the guild.

Examples:
// Edit the guild AFK channel
guild.setAFKChannel(channel)
 .then(updated => console.log(`Updated guild AFK channel to ${guild.afkChannel.name}`))
 .catch(console.error);

setAFKTimeout(
afkTimeout: number
reason?: string
) : Promise<Guild>

Edits the AFK timeout of the guild.

Examples:
// Edit the guild AFK channel
guild.setAFKTimeout(60)
 .then(updated => console.log(`Updated guild AFK timeout to ${guild.afkTimeout}`))
 .catch(console.error);

setBanner() : Promise<Guild>

Sets a new guild banner.

Examples:
guild.setBanner('./banner.png')
 .then(updated => console.log('Updated the guild banner'))
 .catch(console.error);

setDefaultMessageNotifications(
defaultMessageNotifications: GuildDefaultMessageNotifications | null
reason?: string
) : Promise<Guild>

Edits the setting of the default message notifications of the guild.

setDiscoverySplash(
reason?: string
) : Promise<Guild>

Sets a new guild discovery splash image.

Examples:
// Edit the guild discovery splash
guild.setDiscoverySplash('./discoverysplash.png')
  .then(updated => console.log('Updated the guild discovery splash'))
  .catch(console.error);

setExplicitContentFilter(
explicitContentFilter: GuildExplicitContentFilter | null
reason?: string
) : Promise<Guild>

Edits the level of the explicit content filter.

setIcon() : Promise<Guild>

Sets a new guild icon.

Examples:
// Edit the guild icon
guild.setIcon('./icon.png')
 .then(updated => console.log('Updated the guild icon'))
 .catch(console.error);

setMFALevel(
reason?: string
) : Promise<Guild>

Sets the guild's MFA level An elevated MFA level requires guild moderators to have 2FA enabled.

Examples:
// 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);

setName(
name: string
reason?: string
) : Promise<Guild>

Edits the name of the guild.

Examples:
// Edit the guild name
guild.setName('Discord Guild')
 .then(updated => console.log(`Updated guild name to ${updated.name}`))
 .catch(console.error);

setOwner() : Promise<Guild>

Sets a new owner of the guild.

Examples:
// 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);

setPreferredLocale(
preferredLocale: Locale | null
reason?: string
) : Promise<Guild>

Edits the preferred locale of the guild.

Examples:
// Edit the guild preferred locale
guild.setPreferredLocale('en-US')
 .then(updated => console.log(`Updated guild preferred locale to ${guild.preferredLocale}`))
 .catch(console.error);

setPremiumProgressBarEnabled(
enabled?: boolean
reason?: string
) : Promise<Guild>

Edits the enabled state of the guild's premium progress bar

setPublicUpdatesChannel(
publicUpdatesChannel: TextChannelResolvable | null
reason?: string
) : Promise<Guild>

Edits the community updates channel of the guild.

Examples:
// 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 | null
reason?: string
) : Promise<Guild>

Edits the rules channel of the guild.

Examples:
// 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 | null
reason?: string
) : Promise<Guild>

Edits the safety alerts channel of the guild.

Examples:
// 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() : Promise<Guild>

Sets a new guild invite splash image.

Examples:
// Edit the guild splash
guild.setSplash('./splash.png')
 .then(updated => console.log('Updated the guild splash'))
 .catch(console.error);

setSystemChannel(
systemChannel: TextChannelResolvable | null
reason?: string
) : Promise<Guild>

Edits the system channel of the guild.

Examples:
// 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: SystemChannelFlagsResolvable
reason?: string
) : Promise<Guild>

Edits the flags of the default message notifications of the guild.

setVerificationLevel(
verificationLevel: GuildVerificationLevel | null
reason?: string
) : Promise<Guild>

Edits the verification level of the guild.

Examples:
// Edit the guild verification level
guild.setVerificationLevel(1)
 .then(updated => console.log(`Updated guild verification level to ${guild.verificationLevel}`))
 .catch(console.error);

setWidgetSettings() : 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

valueOf() : string

Inherited from: Base

widgetImageURL() : string

Returns a URL for the PNG widget of the guild.