-
Notifications
You must be signed in to change notification settings - Fork 144
Guild
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 |
---|---|---|
client | Client | A shortcut to the client object to which this container is visible. |
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. Equivalent to Date.parseSnowflake(Snowflake.id) . |
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. |
parent | Container/Client | The parent object of to which this container is a child. For example, the parent of a role is the guild in which the role exists. |
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() . |
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. |
banner | string/nil | The hash for the guild's custom banner, if one is set. |
bannerURL | string/nil | The URL that can be used to view the guild's banner, if one is set. |
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) . |
description | string/nil | The guild's custom description, if one exists. |
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 cached. |
lazy | boolean | Whether the guild follows rules for the lazy-loading of client data. |
maxMembers | number/nil | The guild's maximum member count, if available. |
maxPresences | number/nil | The guild's maximum presence count, if available. |
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. |
premiumSubscriptionCount | number | The number of boosts the guild currently has. This may be greater than the number of users who are boosting the guild. |
premiumTier | number | The guild's premium tier (server boost level). See the premiumTier enumeration for a human-readable representation. |
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. |
stickers | Cache | An iterable cache of all stickers that exist in this guild. |
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. |
vanityCode | string/nil | The guild's vanity invite URL code, if one exists. |
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
Defines the behavior of the ==
operator. Allows containers to be directly compared according to their type and __hash
return values.
Returns: boolean
Returns Snowflake.id
Returns: string
Defines the behavior of the tostring
function. All containers follow the format ClassName: hash
.
Returns: string
Returns a unique Date object that represents when the object was created by Discord. Equivalent to Date.fromSnowflake(Snowflake.id)
This method only operates on data in memory.
Returns: Date
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.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
name | string |
Creates a channel category in this guild. The name must be between 2 and 100 characters in length.
This method always makes an HTTP request.
Returns: GuildCategoryChannel
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
This method always makes an HTTP request.
Returns: Emoji
Parameter | Type |
---|---|
name | string |
Creates a new role in this guild. The name must be between 1 and 100 characters in length.
This method always makes an HTTP request.
Returns: Role
Parameter | Type |
---|---|
name | string |
description | string |
tags | string |
file | Base64-Resolvable |
Creates a new sticker in this guild. The name must be between 2 and 30 characters. The description must be between 2 and 100 characters, and the tags must be between 2 and 200 characters. The file must be a PNG, APNG, or LOTTIE file, and must be under 500kb and 320x320 pixels.
This method always makes an HTTP request.
Returns: Sticker
Parameter | Type |
---|---|
name | string |
Creates a new text channel in this guild. The name must be between 2 and 100 characters in length.
This method always makes an HTTP request.
Returns: GuildTextChannel
Parameter | Type |
---|---|
name | string |
Creates a new voice channel in this guild. The name must be between 2 and 100 characters in length.
This method always makes an HTTP request.
Returns: GuildVoiceChannel
Permanently deletes the guild. The current user must owner the server. This cannot be undone!
This method always makes an HTTP request.
Returns: boolean
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. If included, the query parameters include: query.limit: number, query.user: UserId Resolvable query.before: EntryId Resolvable, query.type: ActionType Resolvable
This method always makes an HTTP request.
Returns: Cache
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.
This method always makes an HTTP request.
Returns: Ban
Returns a newly constructed cache of all ban 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.
This method always makes an HTTP request.
Returns: Cache
Parameter | Type |
---|---|
id | Channel-ID-Resolvable |
Gets a text, voice, or category channel object by ID.
This method only operates on data in memory.
Returns: GuildChannel
Parameter | Type |
---|---|
id | Emoji-ID-Resolvable |
Gets a emoji object by ID.
This method only operates on data in memory.
Returns: Emoji
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.
This method always makes an HTTP request.
Returns: Cache
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.
This method may make an HTTP request.
Returns: Member
Parameter | Type | Optional |
---|---|---|
days | number | ✔ |
Returns the number of members that would be pruned from the guild if a prune were to be executed.
This method always makes an HTTP request.
Returns: number
Parameter | Type |
---|---|
id | Role-ID-Resolvable |
Gets a role object by ID.
This method only operates on data in memory.
Returns: Role
Parameter | Type |
---|---|
id | Sticker-ID-Resolvable |
Gets a sticker object by ID.
This method only operates on data in memory.
Returns: Sticker
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.
This method always makes an HTTP request.
Returns: Cache
Parameter | Type | Optional |
---|---|---|
id | User-ID-Resolvable | |
reason | string | ✔ |
Kicks a user/member from the guild with an optional reason.
This method always makes an HTTP request.
Returns: boolean
Removes the current user from the guild.
This method always makes an HTTP request.
Returns: boolean
Returns a raw data table that contains a list of available voice regions for this guild, as provided by Discord, with no additional parsing.
This method always makes an HTTP request.
Returns: table
Parameter | Type | Optional |
---|---|---|
days | number | ✔ |
count | boolean | ✔ |
Prunes (removes) inactive, roleless members from the guild who have not been online in the last provided days. If the count
boolean is provided, the number of pruned members is returned; otherwise, 0
is returned.
This method always makes an HTTP request.
Returns: number
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.
This method always makes a WebSocket request.
Returns: boolean
Parameter | Type |
---|---|
id | Channel-ID-Resolvable |
Sets the guild's AFK channel.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
afk_timeout | number |
Sets the guild's AFK timeout in seconds.
This method always makes an HTTP request.
Returns: number
Parameter | Type |
---|---|
banner | Base64-Resolvable |
Sets the guild's banner. To remove the banner, pass nil
.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
explicit_content_filter | number |
Sets the guild's explicit content level setting. See the explicitContentLevel
enumeration for acceptable values.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
icon | Base64-Resolvable |
Sets the guild's icon. To remove the icon, pass nil
.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
name | string |
Sets the guilds name. This must be between 2 and 100 characters in length.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
default_message_notifications | number |
Sets the guild's default notification setting. See the notficationSetting
enumeration for acceptable values.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
id | User-ID-Resolvable |
Transfers ownership of the guild to another user. Only the current guild owner can do this.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
region | string |
Sets the guild's voice region (eg: us-east
). See listVoiceRegions
for a list of acceptable regions.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
splash | Base64-Resolvable |
Sets the guild's splash. To remove the splash, pass nil
.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
id | Channel-Id-Resolvable |
Sets the guild's join message channel.
This method always makes an HTTP request.
Returns: boolean
Parameter | Type |
---|---|
verification_level | number |
Sets the guild's verification level setting. See the verificationLevel
enumeration for acceptable values.
This method always makes an HTTP request.
Returns: boolean
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!
This method always makes a WebSocket request.
Returns: boolean
Parameter | Type | Optional |
---|---|---|
id | User-ID-Resolvable | |
reason | string | ✔ |
Unbans a user/member from the guild with an optional reason.
This method always makes an HTTP request.
Returns: boolean