DiscordPHP Documentation

Guild extends Part
in package

A Guild is Discord's equivalent of a server. It contains all the Members, Channels, Roles, Bans etc.

Tags
link
https://discord.com/developers/docs/resources/guild
since
2.0.0

Refactored as Part

since
1.0.0

Table of Contents

EXPLICIT_CONTENT_FILTER_ALL_MEMBERS  = 2
EXPLICIT_CONTENT_FILTER_DISABLED  = 0
EXPLICIT_CONTENT_FILTER_MEMBERS_WITHOUT_ROLES  = 1
HUB_TYPE_COLLEGE  = 2
HUB_TYPE_DEFAULT  = 0
HUB_TYPE_HIGH_SCHOOL  = 1
LEVEL_DOUBLE_TABLEFLIP  = 4
LEVEL_LOW  = 1
LEVEL_MEDIUM  = 2
LEVEL_OFF  = 0
LEVEL_TABLEFLIP  = 3
MFA_ELEVATED  = 1
MFA_NONE  = 0
NOTIFICATION_ALL_MESSAGES  = 0
NOTIFICATION_ONLY_MENTIONS  = 1
NSFW_AGE_RESTRICTED  = 3
NSFW_DEFAULT  = 0
NSFW_EXPLICIT  = 1
NSFW_SAFE  = 2
PREMIUM_NONE  = 0
PREMIUM_TIER_1  = 1
PREMIUM_TIER_2  = 2
PREMIUM_TIER_3  = 3
REGION_DEFAULT  = 'us_west'
SUPPRESS_GUILD_REMINDER_NOTIFICATIONS  = 1 << 2
SUPPRESS_JOIN_NOTIFICATION_REPLIES  = 1 << 3
SUPPRESS_JOIN_NOTIFICATIONS  = 1 << 0
SUPPRESS_PREMIUM_SUBSCRIPTION  = 1 << 1
$afk_channel_id  : string
$afk_timeout  : int
$application_id  : string|null
$approximate_member_count  : int|null
$approximate_presence_count  : int|null
$auto_moderation_rules  : AutoModerationRuleRepository
$banner  : string|null
$bans  : BanRepository
$channels  : ChannelRepository
$command_permissions  : CommandPermissionsRepository
$commands  : GuildCommandRepository
$created  : bool
Is the part already created in the Discord servers?
$default_message_notifications  : int
$description  : string|null
$discovery_splash  : string|null
$emojis  : EmojiRepository
$explicit_content_filter  : int
$feature_animated_banner  : bool
$feature_animated_icon  : bool
$feature_application_command_permissions_v2  : bool
$feature_auto_moderation  : bool
$feature_banner  : bool
$feature_community  : bool
$feature_creator_monetizable_provisional  : bool
$feature_creator_store_page  : bool
$feature_developer_support_server  : bool
$feature_discoverable  : bool
$feature_featurable  : bool
$feature_has_directory_entry  : bool
$feature_invite_splash  : bool
$feature_invites_disabled  : bool
$feature_linked_to_hub  : bool
$feature_member_verification_gate_enabled  : bool
$feature_monetization_enabled  : bool
$feature_more_stickers  : bool
$feature_news  : bool
$feature_partnered  : bool
$feature_preview_enabled  : bool
$feature_private_threads  : bool
$feature_raid_alerts_enabled  : bool
$feature_role_icons  : bool
$feature_role_subscriptions_available_for_purchase  : bool
$feature_role_subscriptions_enabled  : bool
$feature_ticketed_events_enabled  : bool
$feature_vanity_url  : bool
$feature_verified  : bool
$feature_vip_regions  : bool
$feature_welcome_screen_enabled  : bool
$features  : array<string|int, string>
$guild_scheduled_events  : ScheduledeventRepository
$icon  : string|null
$icon_hash  : Array|null
$id  : string
$integrations  : IntegrationRepository
$invites  : InviteRepository
$joined_at  : Carbon|null
$large  : bool|null
$max_members  : int|null
$max_presences  : int|null
$max_stage_video_channel_users  : int|null
$max_video_channel_users  : int|null
$member_count  : int|null
$members  : MemberRepository
$mfa_level  : int
$name  : string
$nsfw_level  : int
$owner  : User|null
$owner_id  : string
$preferred_locale  : string
$premium_progress_bar_enabled  : bool
$premium_subscription_count  : int|null
$premium_tier  : int
$public_updates_channel_id  : string|null
$roles  : RoleRepository
$rules_channel_id  : string|null
$safety_alerts_channel_id  : string|null
$scriptData  : mixed
Custom script data.
$splash  : string|null
$splash_hash  : Array|null
$stickers  : StickerRepository
$system_channel_flags  : int
$system_channel_id  : string|null
$templates  : GuildTemplateRepository
$vanity_url_code  : string|null
$verification_level  : int
$voice_states  : array<string|int, object>|null
$welcome_screen  : WelcomeScreen|null
$widget_channel_id  : Array|null
$widget_enabled  : bool|null
$attributes  : array<string|int, mixed>
The parts attributes.
$discord  : Discord
The Discord client.
$factory  : Factory
The factory.
$fillable  : array<string|int, mixed>
The parts fillable attributes.
$hidden  : array<string|int, mixed>
Attributes that are hidden from debug info.
$http  : Http
The HTTP client.
$regions  : Collection|null
An array of valid regions.
$repositories  : array<string|int, mixed>
An array of repositories that can exist in a part.
$repositories_cache  : array<string|int, mixed>
An array of repositories.
$visible  : array<string|int, mixed>
Attributes which are visible from debug info.
__construct()  : mixed
Create a new part instance.
__debugInfo()  : array<string|int, mixed>
Handles debug calls from var_dump and similar functions.
__get()  : mixed
Handles dynamic get calls onto the part.
__serialize()  : array<string|int, mixed>
__set()  : void
Handles dynamic set calls onto the part.
__toString()  : string
Converts the part to a string.
__unserialize()  : void
beginPrune()  : ExtendedPromiseInterface<string|int, ?int>
Begin a prune members operation.
createdTimestamp()  : float
Returns the timestamp of when the guild was created.
createEmoji()  : ExtendedPromiseInterface<string|int, Emoji>
Creates an Emoji for the guild.
createInvite()  : ExtendedPromiseInterface<string|int, Invite>
Attempts to create an Invite to a channel in this guild where possible.
createRole()  : ExtendedPromiseInterface<string|int, Role>
Creates a role.
createSticker()  : ExtendedPromiseInterface<string|int, Sticker>
Creates an Sticker for the guild.
fetch()  : ExtendedPromiseInterface<string|int, self>
Fetches any missing information about the part from Discord's servers.
fill()  : void
Fills the parts attributes from an array.
getAuditLog()  : ExtendedPromiseInterface<string|int, AuditLog>
Returns an audit log object for the query.
getBotPermissions()  : RolePermission|null
Returns the bot's permissions in the guild.
getCreatableAttributes()  : array<string|int, mixed>
Returns the attributes needed to create.
getIconAttribute()  : string|null
Returns the guilds icon.
getInvites()  : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Invite[]>
Returns the channels invites.
getPruneCount()  : ExtendedPromiseInterface<string|int, int>
Returns the number of members that would be removed in a prune operation.
getPublicAttributes()  : array<string|int, mixed>
Returns an array of public attributes.
getRawAttributes()  : array<string|int, mixed>
Returns an array of raw attributes.
getRepositoryAttributes()  : array<string|int, mixed>
Gets the attributes to pass to repositories.
getSplashAttribute()  : string|null
Returns the guild splash.
getUpdatableAttributes()  : array<string|int, mixed>
Returns the updatable attributes.
getVoiceRegions()  : ExtendedPromiseInterface<string|int, Collection>
Gets the voice regions available.
getWelcomeScreen()  : ExtendedPromiseInterface<string|int, WelcomeScreen>
Get the Welcome Screen for the guild.
getWidget()  : ExtendedPromiseInterface<string|int, Widget>
Get the Widget for the guild.
getWidgetSettings()  : ExtendedPromiseInterface
Fetch the Widget Settings for the guild.
isPartial()  : bool
Whether the part is considered partial i.e. missing information which can be fetched from Discord.
jsonSerialize()  : array<string|int, mixed>
Provides data when the part is encoded into JSON. Used for JsonSerializable.
leave()  : ExtendedPromiseInterface
Leaves the guild.
offsetExists()  : bool
Checks if an attribute exists via key. Used for ArrayAccess.
offsetGet()  : mixed
Gets an attribute via key. Used for ArrayAccess.
offsetSet()  : void
Sets an attribute via key. Used for ArrayAccess.
offsetUnset()  : void
Unsets an attribute via key. Used for ArrayAccess.
searchMembers()  : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\User\Member[]>
Returns a list of guild member objects whose username or nickname starts with a provided string.
serialize()  : string|null
Serializes the data. Used for Serializable.
setFeatures()  : ExtendedPromiseInterface<string|int, self>
Modify the guild feature.
transferOwnership()  : ExtendedPromiseInterface
Transfers ownership of the guild to another member.
unban()  : ExtendedPromiseInterface
Unbans a member. Alias for `$guild->bans->unban($user)`.
unserialize()  : void
Unserializes some data and stores it. Used for Serializable.
updateMFALevel()  : ExtendedPromiseInterface<string|int, self>
Modify the Guild `mfa_level`, requires guild ownership.
updateRolePositions()  : ExtendedPromiseInterface<string|int, self>
Updates the positions of a list of given roles.
updateWelcomeScreen()  : ExtendedPromiseInterface<string|int, WelcomeScreen>
Modify the guild's Welcome Screen. Requires the MANAGE_GUILD permission.
updateWidgetSettings()  : ExtendedPromiseInterface
Modify a guild widget settings object for the guild. All attributes may be passed in with JSON and modified. Requires the MANAGE_GUILD permission.
validateRegion()  : ExtendedPromiseInterface
Validates the specified region.
afterConstruct()  : void
Called after the part has been constructed.
getFeatureAnimatedBannerAttribute()  : bool
getFeatureAnimatedIconAttribute()  : bool
getFeatureApplicationCommandPermissionsV2()  : bool
getFeatureAutoModerationAttribute()  : bool
getFeatureBannerAttribute()  : bool
getFeatureCommunityAttribute()  : bool
getFeatureCreatorMonetizableProvisionalAttribute()  : bool
getFeatureCreatorStorePageAttribute()  : bool
getFeatureDeveloperSupportServerAttribute()  : bool
getFeatureDiscoverableAttribute()  : bool
getFeatureFeaturableAttribute()  : bool
getFeatureHasDirectoryEntryAttribute()  : bool
getFeatureInvitesDisabledAttribute()  : bool
getFeatureInviteSplashAttribute()  : bool
getFeatureLinkedToHubAttribute()  : bool
getFeatureMemberVerificationGateEnabledAttribute()  : bool
getFeatureMonetizationEnabledAttribute()  : bool
getFeatureMoreStickersAttribute()  : bool
getFeatureNewsAttribute()  : bool
getFeaturePartneredAttribute()  : bool
getFeaturePreviewEnabledAttribute()  : bool
getFeaturePrivateThreadsAttribute()  : bool
getFeatureRaidAlertsEnabledAttribute()  : bool
getFeatureRoleIconsAttribute()  : bool
getFeatureRoleSubscriptionsAvailableForPurchaseAttribute()  : bool
getFeatureRoleSubscriptionsEnabledAttribute()  : bool
getFeatureTicketedEventsEnabledAttribute()  : bool
getFeatureVanityUrlAttribute()  : bool
getFeatureVerifiedAttribute()  : bool
getFeatureVipRegionsAttribute()  : bool
getFeatureWelcomeScreenEnabledAttribute()  : bool
getIconHashAttribute()  : string|null
Returns the guild icon hash.
getJoinedAtAttribute()  : Carbon|null
Returns the joined_at attribute.
getOwnerAttribute()  : User|null
Returns the owner.
getSplashHashAttribute()  : string|null
Returns the guild splash hash.
getStageInstancesAttribute()  : array<string|int, Collection>|array<string|int, StageInstance>
Returns the channels stage instances.
getWelcomeScreenAttribute()  : WelcomeScreen|null
Returns the Welcome Screen object for the guild.
setEmojisAttribute()  : void
Sets the emojis attribute.
setRolesAttribute()  : void
Sets the roles attribute.
setStickersAttribute()  : void
Sets the stickers attribute.
checkForMutator()  : string|false
Checks if there is a mutator present.
getAttribute()  : mixed
Gets an attribute on the part.
setAttribute()  : void
Sets an attribute on the part.
studly()  : string
Converts a string to studlyCase.

Constants

EXPLICIT_CONTENT_FILTER_ALL_MEMBERS

public mixed EXPLICIT_CONTENT_FILTER_ALL_MEMBERS = 2

EXPLICIT_CONTENT_FILTER_DISABLED

public mixed EXPLICIT_CONTENT_FILTER_DISABLED = 0

EXPLICIT_CONTENT_FILTER_MEMBERS_WITHOUT_ROLES

public mixed EXPLICIT_CONTENT_FILTER_MEMBERS_WITHOUT_ROLES = 1

HUB_TYPE_COLLEGE

public mixed HUB_TYPE_COLLEGE = 2

HUB_TYPE_DEFAULT

public mixed HUB_TYPE_DEFAULT = 0

HUB_TYPE_HIGH_SCHOOL

public mixed HUB_TYPE_HIGH_SCHOOL = 1

LEVEL_DOUBLE_TABLEFLIP

public mixed LEVEL_DOUBLE_TABLEFLIP = 4

LEVEL_LOW

public mixed LEVEL_LOW = 1

LEVEL_MEDIUM

public mixed LEVEL_MEDIUM = 2

LEVEL_OFF

public mixed LEVEL_OFF = 0

LEVEL_TABLEFLIP

public mixed LEVEL_TABLEFLIP = 3

MFA_ELEVATED

public mixed MFA_ELEVATED = 1

MFA_NONE

public mixed MFA_NONE = 0

NOTIFICATION_ALL_MESSAGES

public mixed NOTIFICATION_ALL_MESSAGES = 0

NOTIFICATION_ONLY_MENTIONS

public mixed NOTIFICATION_ONLY_MENTIONS = 1

NSFW_AGE_RESTRICTED

public mixed NSFW_AGE_RESTRICTED = 3

NSFW_DEFAULT

public mixed NSFW_DEFAULT = 0

NSFW_EXPLICIT

public mixed NSFW_EXPLICIT = 1

NSFW_SAFE

public mixed NSFW_SAFE = 2

PREMIUM_NONE

public mixed PREMIUM_NONE = 0

PREMIUM_TIER_1

public mixed PREMIUM_TIER_1 = 1

PREMIUM_TIER_2

public mixed PREMIUM_TIER_2 = 2

PREMIUM_TIER_3

public mixed PREMIUM_TIER_3 = 3

REGION_DEFAULT

public mixed REGION_DEFAULT = 'us_west'

SUPPRESS_GUILD_REMINDER_NOTIFICATIONS

public mixed SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2

SUPPRESS_JOIN_NOTIFICATION_REPLIES

public mixed SUPPRESS_JOIN_NOTIFICATION_REPLIES = 1 << 3

SUPPRESS_JOIN_NOTIFICATIONS

public mixed SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0

SUPPRESS_PREMIUM_SUBSCRIPTION

public mixed SUPPRESS_PREMIUM_SUBSCRIPTION = 1 << 1

Properties

$afk_channel_id

public string $afk_channel_id

The unique identifier of the AFK channel ID.

$afk_timeout

public int $afk_timeout

How long in seconds you will remain in the voice channel until you are moved into the AFK channel. Can be set to: 60, 300, 900, 1800, 3600.

$application_id

public string|null $application_id

Application that made the guild, if made by one.

$approximate_member_count

public int|null $approximate_member_count

Approximate number of members in this guild, returned from the GET /guilds/ endpoint when with_counts is true.

$approximate_presence_count

public int|null $approximate_presence_count

Approximate number of non-offline members in this guild, returned from the GET /guilds/ endpoint when with_counts is true.

$banner

public string|null $banner

Banner hash.

$created

Is the part already created in the Discord servers?

public bool $created = false

Whether the part has been created.

$default_message_notifications

public int $default_message_notifications

Default notification level.

$description

public string|null $description

Guild description of a guild.

$discovery_splash

public string|null $discovery_splash

Discovery splash hash. Only for discoverable guilds.

$explicit_content_filter

public int $explicit_content_filter

Explicit content filter level.

$feature_animated_banner read-only

public bool $feature_animated_banner

Guild has access to set an animated guild banner image.

$feature_animated_icon read-only

public bool $feature_animated_icon

Guild has access to set an animated guild icon.

$feature_application_command_permissions_v2 read-only

public bool $feature_application_command_permissions_v2

Guild is using the old permissions configuration behavior.

$feature_auto_moderation read-only

public bool $feature_auto_moderation

Guild has set up auto moderation rules.

$feature_banner read-only

public bool $feature_banner

Guild has access to set a guild banner image.

$feature_community read-only

public bool $feature_community

Guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates.

$feature_creator_monetizable_provisional read-only

public bool $feature_creator_monetizable_provisional

Guild has enabled monetization.

$feature_creator_store_page read-only

public bool $feature_creator_store_page

Guild has enabled the role subscription promo page.

$feature_developer_support_server read-only

public bool $feature_developer_support_server

Guild has been set as a support server on the App Directory.

$feature_discoverable read-only

public bool $feature_discoverable

Guild is able to be discovered in the directory.

$feature_featurable read-only

public bool $feature_featurable

Guild is able to be featured in the directory.

$feature_has_directory_entry read-only

public bool $feature_has_directory_entry

Guild is listed in a directory channel.

$feature_invite_splash read-only

public bool $feature_invite_splash

Guild has access to set an invite splash background.

$feature_invites_disabled read-only

public bool $feature_invites_disabled

Guild has paused invites, preventing new users from joining.

$feature_linked_to_hub read-only

public bool $feature_linked_to_hub

Guild is in a Student Hub.

$feature_member_verification_gate_enabled read-only

public bool $feature_member_verification_gate_enabled

Guild has enabled membership screening.

$feature_monetization_enabled read-only

public bool $feature_monetization_enabled

Guild has enabled monetization.

$feature_more_stickers read-only

public bool $feature_more_stickers

Guild has increased custom sticker slots.

$feature_news read-only

public bool $feature_news

Guild has access to create news channels.

$feature_partnered read-only

public bool $feature_partnered

Guild is partnered.

$feature_preview_enabled read-only

public bool $feature_preview_enabled

Guild can be previewed before joining via membership screening or the directory.

$feature_private_threads read-only

public bool $feature_private_threads

Guild has access to create private threads.

$feature_raid_alerts_enabled read-only

public bool $feature_raid_alerts_enabled

Guild has enabled alerts for join raids in the configured safety alerts channel.

$feature_role_icons read-only

public bool $feature_role_icons

Guild is able to set role icons.

$feature_role_subscriptions_available_for_purchase read-only

public bool $feature_role_subscriptions_available_for_purchase

Guild has role subscriptions that can be purchased.

$feature_role_subscriptions_enabled read-only

public bool $feature_role_subscriptions_enabled

Guild has enabled role subscriptions.

$feature_ticketed_events_enabled read-only

public bool $feature_ticketed_events_enabled

Guild has enabled ticketed events.

$feature_vanity_url read-only

public bool $feature_vanity_url

Guild has access to set a vanity url.

$feature_verified read-only

public bool $feature_verified

Guild is verified.

$feature_vip_regions read-only

public bool $feature_vip_regions

Guild has access to set 384kbps bitrate in voice.

$feature_welcome_screen_enabled read-only

public bool $feature_welcome_screen_enabled

Guild has enabled the welcome screen.

$features

public array<string|int, string> $features

An array of features that the guild has.

$guild_scheduled_events

public ScheduledeventRepository $guild_scheduled_events

The scheduled events in the guild.

$icon

public string|null $icon

The URL to the guild icon.

$icon_hash

public Array|null $icon_hash

The icon hash for the guild.

$id

public string $id

The unique identifier of the guild.

$joined_at

public Carbon|null $joined_at

A timestamp of when the current user joined the guild.

$large

public bool|null $large

Whether the guild is considered 'large' (over 250 members).

$max_members

public int|null $max_members

Maximum amount of members allowed in the guild.

$max_presences

public int|null $max_presences

Maximum amount of presences allowed in the guild.

$max_stage_video_channel_users

public int|null $max_stage_video_channel_users

Maximum amount of users in a stage video channel.

$max_video_channel_users

public int|null $max_video_channel_users

Maximum amount of users allowed in a video channel.

$member_count

public int|null $member_count

How many members are in the guild.

$mfa_level

public int $mfa_level

MFA level required to join.

$name

public string $name

The name of the guild.

$nsfw_level

public int $nsfw_level

The guild NSFW level.

$owner read-only

public User|null $owner

The owner of the guild.

$owner_id

public string $owner_id

The unique identifier of the owner of the guild.

$preferred_locale

public string $preferred_locale

Preferred locale of the guild.

$premium_progress_bar_enabled

public bool $premium_progress_bar_enabled

Whether the guild has the boost progress bar enabled.

$premium_subscription_count

public int|null $premium_subscription_count

Number of boosts in the guild.

$premium_tier

public int $premium_tier

Server boost level.

$public_updates_channel_id

public string|null $public_updates_channel_id

Notice channel id.

$rules_channel_id

public string|null $rules_channel_id

Channel that the rules are in.

$safety_alerts_channel_id

public string|null $safety_alerts_channel_id

The id of the channel where admins and moderators of Community guilds receive safety alerts from Discord.

$scriptData

Custom script data.

public mixed $scriptData

Used for storing custom information, used by end products.

Tags
deprecated
10.0.0

Relying on this variable with dynamic caching is discouraged.

$splash

public string|null $splash

The URL to the guild splash.

$splash_hash

public Array|null $splash_hash

The splash hash for the guild.

$system_channel_flags

public int $system_channel_flags

Flags for the system channel.

$system_channel_id

public string|null $system_channel_id

Channel that system notifications are posted in.

$vanity_url_code

public string|null $vanity_url_code

Vanity URL code for the guild.

$verification_level

public int $verification_level

The verification level used for the guild.

$voice_states

public array<string|int, object>|null $voice_states

Array of voice states.

$welcome_screen read-only

public WelcomeScreen|null $welcome_screen

The welcome screen of a Community guild, shown to new members, returned in an Invite's guild object. use getWelcomeScreen first to populate.

$widget_channel_id

public Array|null $widget_channel_id

Channel that the widget will create an invite to.

$widget_enabled

public bool|null $widget_enabled

Is server widget enabled.

$attributes

The parts attributes.

protected array<string|int, mixed> $attributes = []

The parts attributes and content.

$discord

The Discord client.

protected Discord $discord

Client.

$fillable

The parts fillable attributes.

protected array<string|int, mixed> $fillable = [ 'id', 'name', 'icon', 'icon_hash', 'description', 'splash', 'discovery_splash', 'features', 'banner', 'owner_id', 'application_id', 'afk_channel_id', 'afk_timeout', 'system_channel_id', 'widget_enabled', 'widget_channel_id', 'verification_level', 'default_message_notifications', 'hub_type', 'mfa_level', 'explicit_content_filter', 'max_presences', 'max_members', 'vanity_url_code', 'premium_tier', 'premium_subscription_count', 'system_channel_flags', 'preferred_locale', 'rules_channel_id', 'public_updates_channel_id', 'max_video_channel_users', 'max_stage_video_channel_users', 'approximate_member_count', 'approximate_presence_count', 'welcome_screen', 'nsfw_level', 'premium_progress_bar_enabled', 'safety_alerts_channel_id', // events 'joined_at', 'large', 'member_count', // repositories 'roles', 'emojis', 'stickers', ]

The array of attributes that can be mass-assigned.

$hidden

Attributes that are hidden from debug info.

protected array<string|int, mixed> $hidden = []

Attributes that are hidden from public.

$http

The HTTP client.

protected Http $http

Client.

$repositories

An array of repositories that can exist in a part.

protected array<string|int, mixed> $repositories = ['roles' => \Discord\Repository\Guild\RoleRepository::class, 'emojis' => \Discord\Repository\Guild\EmojiRepository::class, 'stickers' => \Discord\Repository\Guild\StickerRepository::class, 'members' => \Discord\Repository\Guild\MemberRepository::class, 'channels' => \Discord\Repository\Guild\ChannelRepository::class, 'guild_scheduled_events' => \Discord\Repository\Guild\ScheduledEventRepository::class, 'auto_moderation_rules' => \Discord\Repository\Guild\AutoModerationRuleRepository::class, 'bans' => \Discord\Repository\Guild\BanRepository::class, 'commands' => \Discord\Repository\Guild\GuildCommandRepository::class, 'command_permissions' => \Discord\Repository\Guild\CommandPermissionsRepository::class, 'integrations' => \Discord\Repository\Guild\IntegrationRepository::class, 'invites' => \Discord\Repository\Guild\InviteRepository::class, 'templates' => \Discord\Repository\Guild\GuildTemplateRepository::class]

Repositories.

$repositories_cache

An array of repositories.

protected array<string|int, mixed> $repositories_cache = []

$visible

Attributes which are visible from debug info.

protected array<string|int, mixed> $visible = ['feature_animated_banner', 'feature_animated_icon', 'feature_application_command_permissions_v2', 'feature_auto_moderation', 'feature_banner', 'feature_community', 'feature_creator_monetizable_provisional', 'feature_creator_store_page', 'feature_developer_support_server', 'feature_discoverable', 'feature_featurable', 'feature_has_directory_entry', 'feature_invites_disabled', 'feature_invite_splash', 'feature_linked_to_hub', 'feature_member_verification_gate_enabled', 'feature_monetization_enabled', 'feature_more_stickers', 'feature_news', 'feature_partnered', 'feature_preview_enabled', 'feature_private_threads', 'feature_raid_alerts_enabled', 'feature_role_icons', 'feature_role_subscriptions_available_for_purchase', 'feature_role_subscriptions_enabled', 'feature_ticketed_events_enabled', 'feature_vanity_url', 'feature_verified', 'feature_vip_regions', 'feature_welcome_screen_enabled']

Methods

__construct()

Create a new part instance.

public __construct(Discord $discord[, array<string|int, mixed> $attributes = [] ][, bool $created = false ]) : mixed
Parameters
$discord : Discord

The Discord client.

$attributes : array<string|int, mixed> = []

An array of attributes to build the part.

$created : bool = false

Whether the part has already been created.

Return values
mixed

__debugInfo()

Handles debug calls from var_dump and similar functions.

public __debugInfo() : array<string|int, mixed>
Tags
throws
Exception
see
Part::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

__get()

Handles dynamic get calls onto the part.

public __get(string $key) : mixed
Parameters
$key : string

The attributes key.

Tags
throws
Exception
see
Part::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

The value of the attribute.

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__set()

Handles dynamic set calls onto the part.

public __set(string $key, mixed $value) : void
Parameters
$key : string

The attributes key.

$value : mixed

The attributes value.

Tags
see
self::setAttribute()

This function forwards onto setAttribute.

Return values
void

__toString()

Converts the part to a string.

public __toString() : string
Tags
throws
Exception
see
Part::getPublicAttributes()

This function encodes getPublicAttributes into JSON.

Return values
string

A JSON string of attributes.

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

beginPrune()

Begin a prune members operation.

public beginPrune([array<string|int, mixed> $options = [] ][, string $reason = null ]) : ExtendedPromiseInterface<string|int, ?int>

For large guilds it's recommended to set the compute_prune_count option to false, forcing 'pruned' to null.

Parameters
$options : array<string|int, mixed> = []

An array of options.

$reason : string = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/guild#begin-guild-prune
throws
NoPermissionsException

Missing kick_members permission.

Return values
ExtendedPromiseInterface<string|int, ?int>

The number of members that were removed in the prune operation.

createdTimestamp()

Returns the timestamp of when the guild was created.

public createdTimestamp() : float
Return values
float

createEmoji()

Creates an Emoji for the guild.

public createEmoji(array<string|int, mixed> $options[, string|null $filepath = null ][, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Emoji>
Parameters
$options : array<string|int, mixed>

An array of options.

$filepath : string|null = null

The path to the file if specified will override image data string.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/emoji#create-guild-emoji
throws
NoPermissionsException

Missing manage_emojis_and_stickers permission.

throws
FileNotFoundException

File does not exist.

Return values
ExtendedPromiseInterface<string|int, Emoji>

createInvite()

Attempts to create an Invite to a channel in this guild where possible.

public createInvite(mixed ...$args) : ExtendedPromiseInterface<string|int, Invite>
Parameters
$args : mixed
Tags
see
Channel::createInvite()
throws
RuntimeException

No possible channels to create Invite on.

throws
NoPermissionsException
Return values
ExtendedPromiseInterface<string|int, Invite>

createRole()

Creates a role.

public createRole([array<string|int, mixed> $data = [] ][, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Role>
Parameters
$data : array<string|int, mixed> = []

The data to fill the role with.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/guild#create-guild-role
throws
NoPermissionsException

Missing manage_roles permission.

Return values
ExtendedPromiseInterface<string|int, Role>

createSticker()

Creates an Sticker for the guild.

public createSticker(array<string|int, mixed> $options, string $filepath[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, Sticker>
Parameters
$options : array<string|int, mixed>

An array of options.

$filepath : string

The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/sticker#create-guild-sticker
throws
NoPermissionsException

Missing manage_emojis_and_stickers permission.

throws
FileNotFoundException

The file does not exist.

throws
LengthException

Description is not 2-100 characters long.

throws
DomainException

File format is not PNG, APNG, or Lottie JSON.

throws
RuntimeException

Guild is not verified or partnered to upload Lottie stickers.

Return values
ExtendedPromiseInterface<string|int, Sticker>

fetch()

Fetches any missing information about the part from Discord's servers.

public fetch() : ExtendedPromiseInterface<string|int, self>
Tags
throws
RuntimeException

The part is not fetchable.

Return values
ExtendedPromiseInterface<string|int, self>

fill()

Fills the parts attributes from an array.

public fill(array<string|int, mixed> $attributes) : void
Parameters
$attributes : array<string|int, mixed>

An array of attributes to build the part.

Return values
void

getIconAttribute()

Returns the guilds icon.

public getIconAttribute([string|null $format = null ][, int $size = 1024 ]) : string|null
Parameters
$format : string|null = null

The image format.

$size : int = 1024

The size of the image.

Return values
string|null

The URL to the guild icon or null.

getInvites()

Returns the channels invites.

public getInvites() : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Invite[]>
Tags
link
https://discord.com/developers/docs/resources/guild#get-guild-invites
throws
NoPermissionsException

Missing manage_guild permission.

Return values
ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\Channel\Invite[]>

getPruneCount()

Returns the number of members that would be removed in a prune operation.

public getPruneCount([array<string|int, mixed> $options = [] ]) : ExtendedPromiseInterface<string|int, int>
Parameters
$options : array<string|int, mixed> = []

An array of options.

Tags
link
https://discord.com/developers/docs/resources/guild#get-guild-prune-count
throws
NoPermissionsException

Missing kick_members permission.

Return values
ExtendedPromiseInterface<string|int, int>

The number of members that would be removed.

getPublicAttributes()

Returns an array of public attributes.

public getPublicAttributes() : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

An array of public attributes.

getRawAttributes()

Returns an array of raw attributes.

public getRawAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Raw attributes.

getRepositoryAttributes()

Gets the attributes to pass to repositories.

public getRepositoryAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>

Attributes.

getSplashAttribute()

Returns the guild splash.

public getSplashAttribute([string $format = 'webp' ][, int $size = 2048 ]) : string|null
Parameters
$format : string = 'webp'

The image format.

$size : int = 2048

The size of the image.

Return values
string|null

The URL to the guild splash or null.

getWelcomeScreen()

Get the Welcome Screen for the guild.

public getWelcomeScreen([bool $fresh = false ]) : ExtendedPromiseInterface<string|int, WelcomeScreen>
Parameters
$fresh : bool = false

Whether we should skip checking the cache.

Tags
link
https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen
throws
NoPermissionsException

Missing manage_guild permission when the welcome screen is not enabled.

Return values
ExtendedPromiseInterface<string|int, WelcomeScreen>

isPartial()

Whether the part is considered partial i.e. missing information which can be fetched from Discord.

public isPartial() : bool
Return values
bool

jsonSerialize()

Provides data when the part is encoded into JSON. Used for JsonSerializable.

public jsonSerialize() : array<string|int, mixed>
Tags
throws
Exception
see
Part::getPublicAttributes()

This function forwards onto getPublicAttributes.

Return values
array<string|int, mixed>

An array of public attributes.

leave()

Leaves the guild.

public leave() : ExtendedPromiseInterface
Return values
ExtendedPromiseInterface

offsetExists()

Checks if an attribute exists via key. Used for ArrayAccess.

public offsetExists(string $key) : bool
Parameters
$key : string

The attribute key.

Return values
bool

Whether the offset exists.

offsetGet()

Gets an attribute via key. Used for ArrayAccess.

public offsetGet(string $key) : mixed
Parameters
$key : string

The attribute key.

Tags
throws
Exception
see
Part::getAttribute()

This function forwards onto getAttribute.

Return values
mixed

offsetSet()

Sets an attribute via key. Used for ArrayAccess.

public offsetSet(string $key, mixed $value) : void
Parameters
$key : string

The attribute key.

$value : mixed

The attribute value.

Tags
see
Part::setAttribute()

This function forwards onto setAttribute.

Return values
void

offsetUnset()

Unsets an attribute via key. Used for ArrayAccess.

public offsetUnset(string $key) : void
Parameters
$key : string

The attribute key.

Return values
void

searchMembers()

Returns a list of guild member objects whose username or nickname starts with a provided string.

public searchMembers(array<string|int, mixed> $options) : ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\User\Member[]>
Parameters
$options : array<string|int, mixed>

An array of options. All fields are optional.

Tags
link
https://discord.com/developers/docs/resources/guild#search-guild-members
Return values
ExtendedPromiseInterface<string|int, \Discord\Helpers\Collection|\Discord\Parts\User\Member[]>

serialize()

Serializes the data. Used for Serializable.

public serialize() : string|null
Return values
string|null

A string of serialized data.

setFeatures()

Modify the guild feature.

public setFeatures(array<string|int, bool> $features[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, self>
Parameters
$features : array<string|int, bool>

Array of features to set/unset, e.g. ['COMMUNITY' => true, 'INVITES_DISABLED' => false].

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/guild#modify-guild
link
https://discord.com/developers/docs/resources/guild#guild-object-mutable-guild-features
throws
OutOfRangeException

Feature is not mutable.

throws
RuntimeException

Guild feature is already set.

throws
NoPermissionsException

Missing various permissions: administrator for COMMUNITY or DISCOVERABLE. manage_guild for INVITES_DISABLED or RAID_ALERTS_ENABLED.

Return values
ExtendedPromiseInterface<string|int, self>

This guild.

transferOwnership()

Transfers ownership of the guild to another member.

public transferOwnership(Member|int $member[, string|null $reason = null ]) : ExtendedPromiseInterface
Parameters
$member : Member|int

The member to transfer ownership to.

$reason : string|null = null

Reason for Audit Log.

Tags
throws
RuntimeException

Ownership not transferred correctly.

Return values
ExtendedPromiseInterface

unban()

Unbans a member. Alias for `$guild->bans->unban($user)`.

public unban(User|string $user) : ExtendedPromiseInterface
Parameters
$user : User|string
Tags
see
BanRepository::unban()
throws
NoPermissionsException

Missing ban_members permission.

Return values
ExtendedPromiseInterface

unserialize()

Unserializes some data and stores it. Used for Serializable.

public unserialize(string $data) : void
Parameters
$data : string

Some serialized data.

Tags
see
Part::setAttribute()

The unserialized data is stored with setAttribute.

Return values
void

updateMFALevel()

Modify the Guild `mfa_level`, requires guild ownership.

public updateMFALevel(int $level[, string|null $reason = null ]) : ExtendedPromiseInterface<string|int, self>
Parameters
$level : int

The new MFA level Guild::MFA_NONE or Guild::MFA_ELEVATED.

$reason : string|null = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/guild#modify-guild-mfa-level
Return values
ExtendedPromiseInterface<string|int, self>

This guild.

updateRolePositions()

Updates the positions of a list of given roles.

public updateRolePositions(array<string|int, mixed> $roles) : ExtendedPromiseInterface<string|int, self>
Parameters
$roles : array<string|int, mixed>

Associative array where the LHS key is the position, and the RHS value is a Role object or a string ID, e.g. [1 => 'role_id_1', 3 => 'role_id_3'].

Tags
link
https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
throws
NoPermissionsException

Missing manage_roles permission.

Return values
ExtendedPromiseInterface<string|int, self>

updateWelcomeScreen()

Modify the guild's Welcome Screen. Requires the MANAGE_GUILD permission.

public updateWelcomeScreen(array<string|int, mixed> $options) : ExtendedPromiseInterface<string|int, WelcomeScreen>
Parameters
$options : array<string|int, mixed>

An array of options. All fields are optional.

Tags
link
https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen
throws
NoPermissionsException

Missing manage_guild permission.

Return values
ExtendedPromiseInterface<string|int, WelcomeScreen>

The updated Welcome Screen.

updateWidgetSettings()

Modify a guild widget settings object for the guild. All attributes may be passed in with JSON and modified. Requires the MANAGE_GUILD permission.

public updateWidgetSettings(array<string|int, mixed> $options[, string $reason = null ]) : ExtendedPromiseInterface
Parameters
$options : array<string|int, mixed>

An array of options. enabled => whether the widget is enabled channel_id => the widget channel id

$reason : string = null

Reason for Audit Log.

Tags
link
https://discord.com/developers/docs/resources/guild#modify-guild-widget
throws
NoPermissionsException

Missing manage_guild permission.

Return values
ExtendedPromiseInterface

The updated guild widget object.

validateRegion()

Validates the specified region.

public validateRegion() : ExtendedPromiseInterface
Tags
deprecated
10.0.0

Use Channel::$rtc_region.

see
Guild::REGION_DEFAULT

The default region.

Return values
ExtendedPromiseInterface

afterConstruct()

Called after the part has been constructed.

protected afterConstruct() : void
Return values
void

getFeatureAnimatedBannerAttribute()

protected getFeatureAnimatedBannerAttribute() : bool
Return values
bool

getFeatureAnimatedIconAttribute()

protected getFeatureAnimatedIconAttribute() : bool
Return values
bool

getFeatureApplicationCommandPermissionsV2()

protected getFeatureApplicationCommandPermissionsV2() : bool
Return values
bool

getFeatureAutoModerationAttribute()

protected getFeatureAutoModerationAttribute() : bool
Return values
bool

getFeatureBannerAttribute()

protected getFeatureBannerAttribute() : bool
Return values
bool

getFeatureCommunityAttribute()

protected getFeatureCommunityAttribute() : bool
Return values
bool

getFeatureCreatorMonetizableProvisionalAttribute()

protected getFeatureCreatorMonetizableProvisionalAttribute() : bool
Return values
bool

getFeatureCreatorStorePageAttribute()

protected getFeatureCreatorStorePageAttribute() : bool
Return values
bool

getFeatureDeveloperSupportServerAttribute()

protected getFeatureDeveloperSupportServerAttribute() : bool
Return values
bool

getFeatureDiscoverableAttribute()

protected getFeatureDiscoverableAttribute() : bool
Return values
bool

getFeatureFeaturableAttribute()

protected getFeatureFeaturableAttribute() : bool
Return values
bool

getFeatureHasDirectoryEntryAttribute()

protected getFeatureHasDirectoryEntryAttribute() : bool
Return values
bool

getFeatureInvitesDisabledAttribute()

protected getFeatureInvitesDisabledAttribute() : bool
Return values
bool

getFeatureInviteSplashAttribute()

protected getFeatureInviteSplashAttribute() : bool
Return values
bool

getFeatureLinkedToHubAttribute()

protected getFeatureLinkedToHubAttribute() : bool
Return values
bool

getFeatureMemberVerificationGateEnabledAttribute()

protected getFeatureMemberVerificationGateEnabledAttribute() : bool
Return values
bool

getFeatureMonetizationEnabledAttribute()

protected getFeatureMonetizationEnabledAttribute() : bool
Return values
bool

getFeatureMoreStickersAttribute()

protected getFeatureMoreStickersAttribute() : bool
Return values
bool

getFeatureNewsAttribute()

protected getFeatureNewsAttribute() : bool
Return values
bool

getFeaturePartneredAttribute()

protected getFeaturePartneredAttribute() : bool
Return values
bool

getFeaturePreviewEnabledAttribute()

protected getFeaturePreviewEnabledAttribute() : bool
Return values
bool

getFeaturePrivateThreadsAttribute()

protected getFeaturePrivateThreadsAttribute() : bool
Return values
bool

getFeatureRaidAlertsEnabledAttribute()

protected getFeatureRaidAlertsEnabledAttribute() : bool
Return values
bool

getFeatureRoleIconsAttribute()

protected getFeatureRoleIconsAttribute() : bool
Return values
bool

getFeatureRoleSubscriptionsAvailableForPurchaseAttribute()

protected getFeatureRoleSubscriptionsAvailableForPurchaseAttribute() : bool
Return values
bool

getFeatureRoleSubscriptionsEnabledAttribute()

protected getFeatureRoleSubscriptionsEnabledAttribute() : bool
Return values
bool

getFeatureTicketedEventsEnabledAttribute()

protected getFeatureTicketedEventsEnabledAttribute() : bool
Return values
bool

getFeatureVanityUrlAttribute()

protected getFeatureVanityUrlAttribute() : bool
Return values
bool

getFeatureVerifiedAttribute()

protected getFeatureVerifiedAttribute() : bool
Return values
bool

getFeatureVipRegionsAttribute()

protected getFeatureVipRegionsAttribute() : bool
Return values
bool

getFeatureWelcomeScreenEnabledAttribute()

protected getFeatureWelcomeScreenEnabledAttribute() : bool
Return values
bool

getIconHashAttribute()

Returns the guild icon hash.

protected getIconHashAttribute() : string|null
Return values
string|null

The guild icon hash or null.

getJoinedAtAttribute()

Returns the joined_at attribute.

protected getJoinedAtAttribute() : Carbon|null
Tags
throws
Exception
Return values
Carbon|null

The joined_at attribute.

getOwnerAttribute()

Returns the owner.

protected getOwnerAttribute() : User|null
Return values
User|null

getSplashHashAttribute()

Returns the guild splash hash.

protected getSplashHashAttribute() : string|null
Return values
string|null

The guild splash hash or null.

getStageInstancesAttribute()

Returns the channels stage instances.

protected getStageInstancesAttribute() : array<string|int, Collection>|array<string|int, StageInstance>
Tags
deprecated
10.0.0

Use $channel->stage_instances

Return values
array<string|int, Collection>|array<string|int, StageInstance>

getWelcomeScreenAttribute()

Returns the Welcome Screen object for the guild.

protected getWelcomeScreenAttribute() : WelcomeScreen|null
Return values
WelcomeScreen|null

setEmojisAttribute()

Sets the emojis attribute.

protected setEmojisAttribute(array<string|int, mixed>|null $emojis) : void
Parameters
$emojis : array<string|int, mixed>|null
Return values
void

setRolesAttribute()

Sets the roles attribute.

protected setRolesAttribute(array<string|int, mixed>|null $roles) : void
Parameters
$roles : array<string|int, mixed>|null
Return values
void

setStickersAttribute()

Sets the stickers attribute.

protected setStickersAttribute(array<string|int, mixed>|null $stickers) : void
Parameters
$stickers : array<string|int, mixed>|null
Return values
void

checkForMutator()

Checks if there is a mutator present.

private checkForMutator(string $key, string $type) : string|false
Parameters
$key : string

The attribute name to check.

$type : string

Either get or set.

Return values
string|false

Either a string if it is callable or false.

getAttribute()

Gets an attribute on the part.

private getAttribute(string $key) : mixed
Parameters
$key : string

The key to the attribute.

Tags
throws
Exception
Return values
mixed

Either the attribute if it exists or void.

setAttribute()

Sets an attribute on the part.

private setAttribute(string $key, mixed $value) : void
Parameters
$key : string

The key to the attribute.

$value : mixed

The value of the attribute.

Return values
void

studly()

Converts a string to studlyCase.

private static studly(string $string) : string

This is a port of updated Laravel's implementation, a non-regex with static cache. The Discord\studly() is kept due to unintended bug and we do not want to introduce BC by replacing it. This method is private static as we may move it outside this class in future.

Parameters
$string : string

The string to convert.

Tags
since
10.0.0
Return values
string

Search results