Guild - truemedian/Discordia GitHub Wiki

Inherits Snowflake

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

Methods

requestMembers
sync
getMember
getMember
getEmoji
getChannel
createTextChannel
createVoiceChannel
createCategory
createRole
createEmoji
setName
setRegion
setVerificationLevel
setNotificationSetting
setExplicitContentSetting
setAFKTimeout
setAFKChannel
setSystemChannel
setOwner
setIcon
setSplash
getPruneCount
pruneMembers
getBans
getInvites
getAuditLogs
getWebhooks
listVoiceRegions
leave
delete
kickUser
banUser
unbanUser

Properties

shardId
name
icon
iconURL
splash
splashURL
large
region
mfaLevel
joinedAt
afkTimeout
unavailable
totalMemberCount
verificationLevel
notificationSetting
explicitContentSetting
features
me
owner
ownerId
afkChannelId
afkChannel
systemChannelId
systemChannel
defaultRole
roles
emojis
members
textChannels
voiceChannels
categories

Inherited from Container
client
parent

Inherited from Snowflake
id
createdAt
timestamp

Methods

: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

: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

:getMember( id )

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.

Name Type
id User ID Resolvable

Returns: Member

:getMember( id )

Gets a role object by ID.

Name Type
id User ID Resolvable

Returns: Member

:getEmoji( id )

Gets a emoji object by ID.

Name Type
id Emoji ID Resolvable

Returns: Emoji

:getChannel( id )

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

Name Type
id Channel ID Resolvable

Returns: GuildChannel

:createTextChannel( name )

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

Name Type
name string

Returns: GuildTextChannel

:createVoiceChannel( name )

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

Name Type
name string

Returns: GuildVoiceChannel

:createCategory( name )

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

Name Type
name string

Returns: GuildCategoryChannel

:createRole( name )

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

Name Type
name string

Returns: Role

:createEmoji( name, image )

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

Name Type
name string
image Base64 Resolvable

Returns: Emoji

:setName( name )

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

Name Type
name string

Returns: boolean

:setRegion( region )

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

Name Type
region string

Returns: boolean

:setVerificationLevel( verification_level )

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

Name Type
verification_level number

Returns: boolean

:setNotificationSetting( default_message_notifications )

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

Name Type
default_message_notifications number

Returns: boolean

:setExplicitContentSetting( explicit_content_filter )

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

Name Type
explicit_content_filter number

Returns: boolean

:setAFKTimeout( afk_timeout )

Sets the guild's AFK timeout in seconds.

Name Type
afk_timeout number

Returns: number

:setAFKChannel( id )

Sets the guild's AFK channel.

Name Type
id Channel ID Resolvable

Returns: boolean

:setSystemChannel( id )

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

Name Type
id Channel Id Resolvable

Returns: boolean

:setOwner( id )

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

Name Type
id User ID Resolvable

Returns: boolean

:setIcon( icon )

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

Name Type
icon Base64 Resolvable

Returns: boolean

:setSplash( splash )

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

Name Type
splash Base64 Resolvable

Returns: boolean

:getPruneCount( [ days ] )

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

Name Type Optional
days number x

Returns: number

:pruneMembers( [ days ] )

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

Name Type Optional
days number x

Returns: number

: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

: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

:getAuditLogs( [ query ] )

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

Name Type Optional
query table x

Returns: 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.

Returns: Cache

: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

:leave( )

Removes the current user from the guild.

Returns: boolean

:delete( )

Permanently deletes the guild. This cannot be undone!

Returns: boolean

:kickUser( id, [ reason ] )

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

Name Type Optional
id User ID Resolvable
reason string x

Returns: boolean

:banUser( id, [ reason ], [ days ] )

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.

Name Type Optional Optional
id User ID Resolvable
reason string x
days number x

Returns: boolean

:unbanUser( id, [ reason ] )

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

Name Type Optional
id User ID Resolvable
reason string x

Returns: boolean

Properties

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

Type: number

.name

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

Type: string

.icon

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

Type: string|nil

.iconURL

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

Type: string|nil

.splash

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

Type: 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.

Type: string|nil

.large

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

Type: boolean

.region

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

Type: string

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

Type: number

.joinedAt

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

Type: string

.afkTimeout

The guild's voice AFK timeout in seconds.

Type: number

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

Type: boolean

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

Type: number

.verificationLevel

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

Type: number

.notificationSetting

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

Type: number

.explicitContentSetting

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

Type: number

.features

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

Type: table

.me

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

Type: Member|nil

.owner

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

Type: Member|nil

.ownerId

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

Type: string

.afkChannelId

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

Type: string|nil

.afkChannel

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

Type: GuildVoiceChannel|nil

.systemChannelId

The channel id where Discord's join messages will be displayed

Type: string|nil

.systemChannel

The channel where Discord's join messages will be displayed

Type: GuildTextChannel|nil

.defaultRole

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

Type: Role

.roles

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

Type: 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.

Type: 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.

Type: Cache

.textChannels

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

Type: Cache

.voiceChannels

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

Type: Cache

.categories

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

Type: Cache

Inherited from Container

.client

A shortcut to the client object to which this container is visible.

Type: Client

.parent

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.

Type: Container|Client

Inherited from Snowflake

.id

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.

Type: string

.createdAt

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.

Type: number

.timestamp

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().

Type: string

⚠️ **GitHub.com Fallback** ⚠️