class Guild
extends
AnonymousGuildexport 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.
readonlyVoiceChannel | null afkChannel :
AFK voice channel for this guild
number afkTimeout :
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 if you want to receive this parameter
The approximate amount of presences the guild has You will need to fetch the guild using if you want to receive this parameter
AutoModerationRuleManager autoModerationRules :
A manager of the auto moderation rules of this guild.
boolean available :
Whether the guild is available to access. If it is not available, it indicates a server outage
GuildBanManager bans :
A manager of the bans belonging to this guild
GuildChannelManager channels :
A manager of the channels belonging to this guild
GuildApplicationCommandManager commands :
A manager of the application commands belonging to this guild
GuildDefaultMessageNotifications defaultMessageNotifications :
The default message notification level of the guild
GuildEmojiManager emojis :
A manager of the emojis belonging to this guild
GuildExplicitContentFilter explicitContentFilter :
The explicit content filter level of the guild
`${GuildFeature}`[] features :
An array of features available to this guild
Inherited from: BaseGuild
GuildInviteManager invites :
A manager of the invites of this guild
readonlyDate joinedAt :
The time the client user joined the guild
number joinedTimestamp :
The timestamp the client user joined the guild at
boolean large :
Whether the guild is "large" (has more than members, 50 by default)
readonlynumber maximumBitrate :
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 if you want to receive this parameter
The maximum amount of users allowed in a stage video channel.
number memberCount :
The full amount of members in this guild
GuildMemberManager members :
A manager of the members belonging to this guild
GuildMFALevel mfaLevel :
The required MFA level for this guild
readonlystring nameAcronym :
The acronym that shows up in place of a guild icon
Inherited from: BaseGuild
Snowflake ownerId :
The user id of this guild's owner
Locale preferredLocale :
The preferred locale of the guild, defaults to en-US
boolean premiumProgressBarEnabled :
Whether this guild has its premium (boost) progress bar enabled
The total number of boosts for this server
Inherited from: AnonymousGuild
GuildPremiumTier premiumTier :
The premium tier of this guild
PresenceManager presences :
A manager of the presences belonging to this guild
readonlyTextChannel | null publicUpdatesChannel :
Public updates channel for this guild
RoleManager roles :
A manager of the roles belonging to this guild
readonlyTextChannel | null rulesChannel :
Rules channel for this guild
readonlyTextChannel | null safetyAlertsChannel :
Safety alerts channel for this guild
GuildScheduledEventManager scheduledEvents :
A manager of the scheduled events of this guild
readonlyWebSocketShard shard :
The Shard this Guild belongs to.
number shardId :
The id of the shard this Guild belongs to.
StageInstanceManager stageInstances :
A manager of the stage instances of this guild
GuildStickerManager stickers :
A manager of the stickers belonging to this guild
readonlyTextChannel | null systemChannel :
System channel for this guild
Readonly<SystemChannelFlagsBitField> systemChannelFlags :
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
GuildVerificationLevel verificationLevel :
The verification level of the guild
Inherited from: AnonymousGuild
readonlyInternalDiscordGatewayAdapterCreator voiceAdapterCreator :
The voice state adapter for this guild that can be used with discordjs/voice to play audio in voice and stage channels.
VoiceStateManager voiceStates :
A manager of the voice states of this guild
readonlyTextChannel | NewsChannel | VoiceBasedChannel | ForumChannel | MediaChannel | null widgetChannel :
Widget channel for this guild
bannerURLoptions?: 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);
discoverySplashURLoptions?: ImageURLOptions) : string | null (
The URL to this guild's discovery splash image.
editoptions: 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);
editOnboardingoptions: GuildOnboardingEditOptions) : Promise<GuildOnboarding> (
Edits the guild onboarding data for this guild.
editWelcomeScreenoptions: 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.
fetchAuditLogsEvent? extends GuildAuditLogsResolvable = null
>(options?: GuildAuditLogsFetchOptions<Event>) : Promise<GuildAuditLogs<Event>> <
Event? extends GuildAuditLogsResolvable = null
Fetches audit logs for this guild.
// Output audit log entries
guild.fetchAuditLogs()
.then(audit => console.log(audit.entries.first()))
.catch(console.error);
fetchIntegrationsPromise<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);
fetchOnboardingPromise<GuildOnboarding> () :
Fetches the guild onboarding data for this guild.
fetchOwneroptions?: BaseFetchOptions) : Promise<GuildMember> (
Fetches the owner of the guild. If the member object isn't needed, use ownerId instead.
fetchPreviewPromise<GuildPreview> () :
Obtains a guild preview for this guild from Discord.
fetchTemplatesPromise<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);
fetchWebhooksPromise<Collection<Snowflake, Webhook>> () :
Fetches all webhooks for the guild.
// Fetch webhooks
guild.fetchWebhooks()
.then(webhooks => console.log(`Fetched ${webhooks.size} webhooks`))
.catch(console.error);
fetchWelcomeScreenPromise<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);
fetchWidgetSettingsPromise<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);
iconURLoptions?: 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);
setAFKChannelafkChannel: 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);
setBannerbanner: 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);
setDefaultMessageNotificationsdefaultMessageNotifications: GuildDefaultMessageNotifications | nullreason?: string) : Promise<Guild> (
Edits the setting of the default message notifications of the guild.
setDiscoverySplashdiscoverySplash: 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);
setExplicitContentFilterexplicitContentFilter: GuildExplicitContentFilter | nullreason?: string) : Promise<Guild> (
Edits the level of the explicit content filter.
setIconicon: 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);
setMFALevellevel: 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);
setOwnerowner: 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
setPublicUpdatesChannelpublicUpdatesChannel: 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);
setRulesChannelrulesChannel: 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);
setSafetyAlertsChannelsafetyAlertsChannel: 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);
setSplashsplash: 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);
setSystemChannelsystemChannel: 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);
setSystemChannelFlagssystemChannelFlags: SystemChannelFlagsResolvablereason?: string) : Promise<Guild> (
Edits the flags of the default message notifications of the guild.
setVerificationLevelverificationLevel: 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);
setWidgetSettingssettings: GuildWidgetSettingsDatareason?: string) : Promise<Guild> (
Edits the guild's widget settings.
splashURLoptions?: ImageURLOptions) : string | null (
The URL to this guild's invite splash image.
Inherited from: AnonymousGuild
toJSONunknown () :
toStringstring () :
When concatenated with a string, this automatically returns the guild's name instead of the Guild object.
Inherited from: BaseGuild
widgetImageURLstyle?: GuildWidgetStyle) : string (
Returns a URL for the PNG widget of the guild.