Skip to content
SinisterRectus edited this page Sep 5, 2018 · 43 revisions

extends Snowflake

Represents a Discord guild (or server). Guilds are a collection of members, channels, and roles that represents one community.

Instances of this class should not be constructed by users.

Properties Inherited From Snowflake

Name Type Description
createdAt number The Unix time in seconds at which this object was created by Discord. Additional decimal points may be present, though only the first 3 (milliseconds) should be considered accurate.
id string The Snowflake ID that can be used to identify the object. This is guaranteed to be unique except in cases where an object shares the ID of its parent.
timestamp string The date and time at which this object was created by Discord, represented as an ISO 8601 string plus microseconds when available. Equivalent to Date.fromSnowflake(Snowflake.id):toISO().

Properties

Name Type Description
afkChannel GuildVoiceChannel/nil Equivalent to Guild.voiceChannels:get(Guild.afkChannelId).
afkChannelId string/nil The Snowflake ID of the channel that is used for AFK members, if one is set.
afkTimeout number The guild's voice AFK timeout in seconds.
categories Cache An iterable cache of all channel categories that exist in this guild.
connection VoiceConnection/nil The VoiceConnection for this guild if one exists.
defaultRole Role Equivalent to Guild.roles:get(Guild.id).
emojis Cache An iterable cache of all emojis that exist in this guild. Note that standard unicode emojis are not found here; only custom emojis.
explicitContentSetting number The guild's explicit content level setting. See the explicitContentLevel enumeration for a human-readable representation.
features table Raw table of VIP features that are enabled for the guild.
icon string/nil The hash for the guild's custom icon, if one is set.
iconURL string/nil The URL that can be used to view the guild's icon, if one is set.
joinedAt string The date and time at which the current user joined the guild, represented as an ISO 8601 string plus microseconds when available.
large boolean Whether the guild has an arbitrarily large amount of members. Guilds that are "large" will not initialize with all members.
lazy boolean Whether the guild has follows rules for the lazy-loading of client data.
me Member/nil Equivalent to Guild.members:get(Guild.client.user.id).
members Cache An iterable cache of all members that exist in this guild and have been already loaded. If the cacheAllMembers client option (and the syncGuilds option for user-accounts) is enabled on start-up, then all members will be cached. Otherwise, offline members may not be cached. To access a member that may exist, but is not cached, use Guild:getMember.
mfaLevel number The guild's multi-factor (or two-factor) verification level setting. A value of 0 indicates that MFA is not required; a value of 1 indicates that MFA is required for administrative actions.
name string The guild's name. This should be between 2 and 100 characters in length.
notificationSetting number The guild's default notification setting. See the notficationSetting enumeration for a human-readable representation.
owner Member/nil Equivalent to Guild.members:get(Guild.ownerId).
ownerId string The Snowflake ID of the guild member that owns the guild.
region string The voice region that is used for all voice connections in the guild.
roles Cache An iterable cache of all roles that exist in this guild. This includes the default everyone role.
shardId number The ID of the shard on which this guild is served. If only one shard is in operation, then this will always be 0.
splash string/nil The hash for the guild's custom splash image, if one is set. Only partnered guilds may have this.
splashURL string/nil The URL that can be used to view the guild's custom splash image, if one is set. Only partnered guilds may have this.
systemChannel GuildTextChannel/nil The channel where Discord's join messages will be displayed
systemChannelId string/nil The channel id where Discord's join messages will be displayed
textChannels Cache An iterable cache of all text channels that exist in this guild.
totalMemberCount number The total number of members that belong to this guild. This should always be greater than or equal to the total number of cached members.
unavailable boolean Whether the guild is unavailable. If the guild is unavailable, then no property is guaranteed to exist except for this one and the guild's ID.
verificationLevel number The guild's verification level setting. See the verificationLevel enumeration for a human-readable representation.
voiceChannels Cache An iterable cache of all voice channels that exist in this guild.

Methods Inherited From Snowflake

__hash()

Returns Snowflake.id

Returns: string

Methods

banUser(id, reason, days)

Parameter Type Optional
id User-ID-Resolvable
reason string
days number

Bans a user/member from the guild with an optional reason. The days parameter is the number of days to consider when purging messages, up to 7.

Returns: boolean

createCategory(name)

Parameter Type
name string

Creates a channel category in this guild. The name must be between 2 and 100 characters in length.

Returns: GuildCategoryChannel

createEmoji(name, image)

Parameter Type
name string
image Base64-Resolvable

Creates a new emoji in this guild. The name must be between 2 and 32 characters in length. The image must not be over 256kb, any higher will return a 400 Bad Request

Returns: Emoji

createRole(name)

Parameter Type
name string

Creates a new role in this guild. The name must be between 1 and 100 characters in length.

Returns: Role

createTextChannel(name)

Parameter Type
name string

Creates a new text channel in this guild. The name must be between 2 and 100 characters in length.

Returns: GuildTextChannel

createVoiceChannel(name)

Parameter Type
name string

Creates a new voice channel in this guild. The name must be between 2 and 100 characters in length.

Returns: GuildVoiceChannel

delete()

Permanently deletes the guild. This cannot be undone!

Returns: boolean

getAuditLogs(query)

Parameter Type Optional
query table

Returns a newly constructed cache of audit log entry objects for the guild. The cache and its objects are not automatically updated via gateway events. You must call this method again to get the updated objects. - query.limit: number - query.user: UserId Resolvable - query.before: EntryId Resolvable - query.type: ActionType Resolvable

Returns: Cache

getBan(id)

Parameter Type
id User-ID-Resolvable

This will return a Ban object for a giver user if that user is banned from the guild; otherwise, nil is returned.

Returns: Ban

getBans()

Returns a newly constructed cache of all ban objects for the guild. The cache is not automatically updated via gateway events, but the internally referenced user objects may be updated. You must call this method again to guarantee that the objects are up to date.

Returns: Cache

getChannel(id)

Parameter Type
id Channel-ID-Resolvable

Gets a text, voice, or category channel object by ID.

Returns: GuildChannel

getEmoji(id)

Parameter Type
id Emoji-ID-Resolvable

Gets a emoji object by ID.

Returns: Emoji

getInvites()

Returns a newly constructed cache of all invite objects for the guild. The cache and its objects are not automatically updated via gateway events. You must call this method again to get the updated objects.

Returns: Cache

getMember(id)

Parameter Type
id User-ID-Resolvable

Gets a member object by ID. If the object is already cached, then the cached object will be returned; otherwise, an HTTP request is made.

Returns: Member

getPruneCount(days)

Parameter Type Optional
days number

Returns the number of members that would be pruned from the guild if a prune were to be executed.

Returns: number

getRole(id)

Parameter Type
id Role-ID-Resolvable

Gets a role object by ID.

Returns: Role

getWebhooks()

Returns a newly constructed cache of all webhook objects for the guild. The cache and its objects are not automatically updated via gateway events. You must call this method again to get the updated objects.

Returns: Cache

kickUser(id, reason)

Parameter Type Optional
id User-ID-Resolvable
reason string

Kicks a user/member from the guild with an optional reason.

Returns: boolean

leave()

Removes the current user from the guild.

Returns: boolean

listVoiceRegions()

Returns a raw data table that contains a list of available voice regions for this guild, as provided by Discord, with no additional parsing.

Returns: table

pruneMembers(days)

Parameter Type Optional
days number

Prunes (removes) inactive, roleless members from the guild.

Returns: number

requestMembers()

Asynchronously loads all members for this guild. You do not need to call this if the cacheAllMembers client option (and the syncGuilds option for user-accounts) is enabled on start-up.

Returns: boolean

setAFKChannel(id)

Parameter Type
id Channel-ID-Resolvable

Sets the guild's AFK channel.

Returns: boolean

setAFKTimeout(afk_timeout)

Parameter Type
afk_timeout number

Sets the guild's AFK timeout in seconds.

Returns: number

setExplicitContentSetting(explicit_content_filter)

Parameter Type
explicit_content_filter number

Sets the guild's explicit content level setting. See the explicitContentLevel enumeration for acceptable values.

Returns: boolean

setIcon(icon)

Parameter Type
icon Base64-Resolvable

Sets the guild's icon. To remove the icon, pass nil.

Returns: boolean

setName(name)

Parameter Type
name string

Sets the guilds name. This must be between 2 and 100 characters in length.

Returns: boolean

setNotificationSetting(default_message_notifications)

Parameter Type
default_message_notifications number

Sets the guild's default notification setting. See the notficationSetting enumeration for acceptable values.

Returns: boolean

setOwner(id)

Parameter Type
id User-ID-Resolvable

Transfers ownership of the guild to another user. Only the current guild owner can do this.

Returns: boolean

setRegion(region)

Parameter Type
region string

Sets the guild's voice region (eg: us-east). See listVoiceRegions for a list of acceptable regions.

Returns: boolean

setSplash(splash)

Parameter Type
splash Base64-Resolvable

Sets the guild's splash. To remove the splash, pass nil.

Returns: boolean

setSystemChannel(id)

Parameter Type
id Channel-Id-Resolvable

Transfers ownership of the guild to another user. Only the current guild owner can do this.

Returns: boolean

setVerificationLevel(verification_level)

Parameter Type
verification_level number

Sets the guild's verification level setting. See the verificationLevel enumeration for acceptable values.

Returns: boolean

sync()

Asynchronously loads certain data and enables the receiving of certain events for this guild. You do not need to call this if the syncGuilds client option is enabled on start-up. Note: This is only for user accounts. Bot accounts never need to sync guilds!

Returns: boolean

unbanUser(id, reason)

Parameter Type Optional
id User-ID-Resolvable
reason string

Unbans a user/member from the guild with an optional reason.

Returns: boolean

Clone this wiki locally