Skip to content
Nameless edited this page Feb 19, 2018 · 43 revisions

extends Snowflake

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

Methods

boolean 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.

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!

Member getMember(id)

  • id: User ID Resolveable

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.

Role getRole(id)

  • id: Role ID Resolveable

Gets a role object by ID.

GuildChannel getChannel(id)

  • id: Channel ID Resolveable

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

GuildTextChannel createTextChannel(name)

  • name: string

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

GuildVoiceChannel createVoiceChannel(name)

  • name: string

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

GuildCategoryChannel createCategory(name)

  • name: string

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

Role createRole(name)

  • name: string

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

boolean setName(name)

  • name: string

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

boolean setRegion(region)

  • region: string

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

boolean setVerificationLevel(verificationLevel)

  • verificationLevel: number

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

boolean setNotificationSetting(notificationSetting)

  • notificationSetting: number

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

boolean setExplicitContentSetting(explicitContentSetting)

  • explicitContentSetting: number

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

boolean setAFKTimeout(afkTimeout)

  • afkTimeout: number

Sets the guild's AFK timeout in seconds.

boolean setAFKChannel(id)

  • id: Channel ID Resolveable

Sets the guild's AFK channel.

boolean setOwner(id)

  • id: User ID Resolveable

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

boolean setIcon(icon)

  • icon: Base64 Resolveable

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

boolean setSplash(splash)

  • splash: Base64 Resolveable

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

number getPruneCount(days)

  • days: number

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

number pruneMembers(days)

  • days: number

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

Cache 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.

Cache 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.

Cache getAuditLogs([query])

  • query: table
  • query.limit: number
  • query.user_id: UserId Resolvable
  • query.before: EntryId Resolvable
  • query.action_type: ActionType Resolvable 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.

Cache 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.

table 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.

boolean leave()

Removes the current user from the guild.

boolean delete()

Permanently deletes the guild. This cannot be undone!

boolean kickUser(id[, reason])

  • id: User ID Resolveable
  • reason: string

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

boolean banUser(id[, reason, days])

  • id: User ID Resolveable
  • 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.

boolean unbanUser(id[, reason])

  • id: User ID Resolveable
  • reason: string

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

Properties

number shardId

The ID of the shard on which this guild is served. If only one shard is in operation, then this will always be 0.

string name

The guild's name. This should be between 2 and 100 characters in length.

string|nil icon

The hash for the guild's custom icon, if one is set.

string|nil iconURL

The URL that can be used to view the guild's icon, if one is set.

string|nil splash

The hash for the guild's custom splash image, if one is set. Only partnered guilds may have this.

string|nil splashURL

The URL that can be used to view the guild's custom splash image, if one is set. Only partnered guilds may have this.

boolean large

Whether the guild has an arbitrarily large amount of members. Guilds that are "large" will not initialize with all members.

string region

The voice region that is used for all voice connections in the guild.

number mfaLevel

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.

string joinedAt

The date and time at which the current user joined the guild, represented as an ISO 8601 string plus microseconds when available.

number afkTimeout

The guild's voice AFK timeout in seconds.

boolean unavailable

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.

number totalMemberCount

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.

number verificationLevel

The guild's verification level setting. See the verificationLevel enumeration for a human-readable representation.

number notificationSetting

The guild's default notification setting. See the notficationSetting enumeration for a human-readable representation.

number explicitContentSetting

The guild's explicit content level setting. See the explicitContentLevel enumeration for a human-readable representation.

table features

Raw table of VIP features that are enabled for the guild.

Member|nil me

Equivalent to Guild.members:get(Guild.client.user.id).

Member|nil owner

Equivalent to Guild.members:get(Guild.ownerId).

string ownerId

The Snowflake ID of the guild member that owns the guild.

string|nil afkChannelId

The Snowflake ID of the channel that is used for AFK members, if one is set.

GuildVoiceChannel|nil afkChannel

Equivalent to Guild.voiceChannels:get(Guild.afkChannelId).

Role defaultRole

Equivalent to Guild.roles:get(Guild.id).

Cache roles

An iterable cache of all roles that exist in this guild. This includes the default everyone role.

Cache emojis

An iterable cache of all emojis that exist in this guild. Note that standard unicode emojis are not found here; only custom emojis.

Cache members

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.

Cache textChannels

An iterable cache of all text channels that exist in this guild.

Cache voiceChannels

An iterable cache of all voice channels that exist in this guild.

Cache categories

An iterable cache of all channel categories that exist in this guild.

Clone this wiki locally