Skip to main content
A Guild is a server (“guild” is the name Discord gives servers in its API). You get one as the guild of a command used in a server, with the events that happen in one, and as member.guild, role.guild or channel.guild.
How your functions receive a server is in Commands and Events. What a server remembers about its members, and why not all of them, is in Memory.

Properties

Snowflake
The unique id Discord gave it.
Date
When it was created: a Discord id contains its creation date.
string
The name of the server.
string | null
The description of the server, when it has one.
Snowflake
The id of the user who owns the server.
boolean
false during an outage of Discord: the data may be out of date.
number | null
How many members the server has. Exact when the bot receives member events, approximate otherwise; null when Discord never said it.
readonly GuildFeature[]
What the server has enabled or unlocked (COMMUNITY, VANITY_URL…). See GuildFeature.
VerificationLevel
What Discord asks of new members before they can write. See VerificationLevel.
PremiumTier
The boost level of the server. See PremiumTier.
number
How many boosts the server has.
Locale
The language of the server, used for what Discord sends to it. See Locale.
string | null
The code of the custom invite link of the server, when it has one.
Snowflake | null
The id of the channel where Discord posts welcome messages.
Snowflake | null
The id of the channel that shows the rules, in a community server.
Snowflake | null
The id of the voice channel inactive members are moved to.
Date | null
When the bot joined the server, when Discord said it.
ReadonlyMap<Snowflake, Role>
The roles of the server, @everyone included.
ReadonlyMap<Snowflake, GuildMember>
The members of the server the bot knows: the ones seen the most recently, not all of them.
ReadonlyMap<Snowflake, GuildChannel | ThreadChannel>
The channels and active threads of the server.
ReadonlyMap<Snowflake, GuildEmoji>
The custom emojis of the server.
VoiceConnection | null
The bot in voice in this server, to play or leave; null when it is in no voice channel here. See VoiceConnection.
Role
The @everyone role, which every member has.
GuildMember
The bot as a member of this server.
members only holds the members the bot has seen lately (see Memory). Use fetchMember() to get one for sure. me is always there, whatever the bot remembers.

Helpers

These read what the bot remembers: they never send a request.

iconURL()

The URL of the icon of the server, when it has one. See ImageOptions.

bannerURL()

The URL of the banner of the server, when it has one. See ImageOptions.

splashURL()

The URL of the invite background of the server, when it has one. See ImageOptions.

toString()

The name of the server.

toJSON()

The data of Discord as a plain object, with camelCase names.

Reading from Discord

fetch()

Asks Discord for the latest data of the server. Discord documentation

fetchMember()

A member of the server: from what the bot remembers, or else from Discord. Discord documentation

fetchMembers()

Members of the server, by pages of 1000 at most, ordered by id. Needs the Server Members intent to be enabled for the bot. limit is a whole number between 1 and 1000 (the default); after is the id of the last member of the previous page. Discord documentation

searchMembers()

Members whose username or nickname starts with the given text. limit is 1 by default. Discord documentation

fetchOwner()

The member who owns the server.

fetchBan()

The ban of a user; null when they are not banned. See Ban. Discord documentation

fetchBans()

The bans of the server, by pages of 1000 at most. See Ban. Discord documentation

fetchRoles()

Asks Discord for the roles of the server. Discord documentation

fetchChannels()

The channels of the server (threads are not included). Discord documentation

fetchActiveThreads()

The threads of the server that are not archived. Discord documentation

fetchEmojis()

Asks Discord for the custom emojis of the server. Discord documentation

fetchInvites()

The invites of the server, with how many times each was used. Discord documentation

fetchWebhooks()

The webhooks of every channel of the server. Discord documentation

fetchAuditLog()

What moderators and bots did in the server. The options are the audit log filters; the result is an AuditLog. Discord documentation

fetchScheduledEvents()

The scheduled events of the server. See ScheduledEvent. Discord documentation

fetchAutoModerationRules()

The auto moderation rules of the server. See AutoModerationRule. Discord documentation

fetchStickers()

The custom stickers of the server. See Sticker. Discord documentation

Actions

edit()

Changes the settings of the server. See GuildEditOptions. Discord documentation

leave()

Makes the bot leave the server. Discord documentation

kick()

Removes a member from the server; they can come back with an invite. Discord documentation

ban()

Bans a user from the server, member or not. See BanOptions. Discord documentation

bulkBan()

Bans up to 200 users at once. Returns the ids of the users that were banned, and of those that could not be. See BanOptions. Discord documentation

unban()

Lifts the ban of a user. Discord documentation

createRole()

Creates a role. See RoleCreateOptions. Discord documentation

createChannel()

Creates a channel. See ChannelCreateOptions. Discord documentation

createEmoji()

Adds a custom emoji to the server. options.image is the image as a data URI (data:image/png;base64,...). Discord documentation

createScheduledEvent()

Schedules an event in the server. The options are the scheduled event options; the result is a ScheduledEvent. Discord documentation

Types

GuildFeature

What a server has enabled or unlocked, as Discord names it: one of 'ANIMATED_BANNER', 'ANIMATED_ICON', 'APPLICATION_COMMAND_PERMISSIONS_V2', 'AUTO_MODERATION', 'BANNER', 'COMMUNITY', 'CREATOR_MONETIZABLE_PROVISIONAL', 'CREATOR_STORE_PAGE', 'DEVELOPER_SUPPORT_SERVER', 'DISCOVERABLE', 'ENHANCED_ROLE_COLORS', 'FEATURABLE', 'GUILD_TAGS', 'GUESTS_ENABLED', 'INVITES_DISABLED', 'INVITE_SPLASH', 'MEMBER_VERIFICATION_GATE_ENABLED', 'MORE_SOUNDBOARD', 'MORE_STICKERS', 'NEWS', 'PARTNERED', 'PREVIEW_ENABLED', 'PRUNE_REQUIRES_ADMIN', 'RAID_ALERTS_DISABLED', 'ROLE_ICONS', 'ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE', 'ROLE_SUBSCRIPTIONS_ENABLED', 'SOUNDBOARD', 'TICKETED_EVENTS_ENABLED', 'VANITY_URL', 'VERIFIED', 'VIP_REGIONS', 'WELCOME_SCREEN_ENABLED'. Discord adds features over time, so any other text is accepted too: guild.features.includes('COMMUNITY') is typed, and an unknown feature does not break anything. Discord documentation

Audit log filters

What fetchAuditLog() takes. Every field can be left out.
Snowflake
Only the entries of this user.
AuditLogEvent
Only the entries of this kind of action. See AuditLogEvent.
Snowflake
Only the entries with an id lower than this audit log entry id.
Snowflake
Only the entries with an id higher than this audit log entry id.
number
How many entries at most, between 1 and 100; 50 by default.
Discord documentation

Scheduled event options

What createScheduledEvent() takes. Dates are ISO 8601 texts (date.toISOString()); the image is a data URI (data:image/png;base64,...).
string
required
The name of the scheduled event.
number
required
The privacy level of the scheduled event: 2 (only the members of the server).
string
required
The time to schedule the scheduled event.
number
required
Where the event takes place: 1 in a stage channel, 2 in a voice channel, 3 somewhere else (entityMetadata.location then says where).
Snowflake
The channel id of the scheduled event.
{ location?: string }
The entity metadata of the scheduled event: location is where it takes place (1-100 characters).
string
The time when the scheduled event is scheduled to end.
string
The description of the scheduled event.
string
The cover image of the scheduled event.
object
The definition for how often this event should recur, as Discord describes it.
Discord documentation

Other types