Skip to content

Commit

Permalink
Add guild feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcole1340 committed Aug 30, 2021
1 parent 80254f0 commit 7ce6256
Showing 1 changed file with 185 additions and 37 deletions.
222 changes: 185 additions & 37 deletions src/Discord/Parts/Guild/Guild.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,45 +33,66 @@
/**
* A Guild is Discord's equivalent of a server. It contains all the Members, Channels, Roles, Bans etc.
*
* @property string $id The unique identifier of the guild.
* @property string $name The name of the guild.
* @property string $icon The URL to the guild icon.
* @property string $icon_hash The icon hash for the guild.
* @property string $region The region the guild's voice channels are hosted in.
* @property User $owner The owner of the guild.
* @property string $owner_id The unique identifier of the owner of the guild.
* @property Carbon $joined_at A timestamp of when the current user joined the guild.
* @property string $afk_channel_id The unique identifier of the AFK channel ID.
* @property int $afk_timeout How long you will remain in the voice channel until you are moved into the AFK channel.
* @property string[] $features An array of features that the guild has.
* @property string $splash The URL to the guild splash.
* @property string $discovery_splash Discovery splash hash. Only for discoverable guilds.
* @property string $splash_hash The splash hash for the guild.
* @property bool $large Whether the guild is considered 'large' (over 250 members).
* @property int $verification_level The verification level used for the guild.
* @property int $member_count How many members are in the guild.
* @property int $default_message_notifications Default notification level.
* @property int $explicit_content_filter Explicit content filter level.
* @property int $mfa_level MFA level required to join.
* @property string $application_id Application that made the guild, if made by one.
* @property bool $widget_enabled Is server widget enabled.
* @property string $widget_channel_id Channel that the widget will create an invite to.
* @property string $system_channel_id Channel that system notifications are posted in.
* @property int $system_channel_flags Flags for the system channel.
* @property string $rules_channel_id Channel that the rules are in.
* @property object[] $voice_states Array of voice states.
* @property int $max_presences Maximum amount of presences allowed in the guild.
* @property int $max_members Maximum amount of members allowed in the guild.
* @property string $vanity_url_code Vanity URL code for the guild.
* @property string $description Guild description if it is discoverable.
* @property string $banner Banner hash.
* @property int $premium_tier Server boost level.
* @property int $premium_subscription_count Number of boosts in the guild.
* @property string $preferred_locale Preferred locale of the guild.
* @property string $public_updates_channel_id Notice channel id.
* @property int $max_video_channel_users Maximum amount of users allowed in a video channel.
* @property string $id The unique identifier of the guild.
* @property string $name The name of the guild.
* @property string $icon The URL to the guild icon.
* @property string $icon_hash The icon hash for the guild.
* @property string $region The region the guild's voice channels are hosted in.
* @property User $owner The owner of the guild.
* @property string $owner_id The unique identifier of the owner of the guild.
* @property Carbon $joined_at A timestamp of when the current user joined the guild.
* @property string $afk_channel_id The unique identifier of the AFK channel ID.
* @property int $afk_timeout How long you will remain in the voice channel until you are moved into the AFK channel.
* @property string[] $features An array of features that the guild has.
* @property string $splash The URL to the guild splash.
* @property string $discovery_splash Discovery splash hash. Only for discoverable guilds.
* @property string $splash_hash The splash hash for the guild.
* @property bool $large Whether the guild is considered 'large' (over 250 members).
* @property int $verification_level The verification level used for the guild.
* @property int $member_count How many members are in the guild.
* @property int $default_message_notifications Default notification level.
* @property int $explicit_content_filter Explicit content filter level.
* @property int $mfa_level MFA level required to join.
* @property string $application_id Application that made the guild, if made by one.
* @property bool $widget_enabled Is server widget enabled.
* @property string $widget_channel_id Channel that the widget will create an invite to.
* @property string $system_channel_id Channel that system notifications are posted in.
* @property int $system_channel_flags Flags for the system channel.
* @property string $rules_channel_id Channel that the rules are in.
* @property object[] $voice_states Array of voice states.
* @property int $max_presences Maximum amount of presences allowed in the guild.
* @property int $max_members Maximum amount of members allowed in the guild.
* @property string $vanity_url_code Vanity URL code for the guild.
* @property string $description Guild description if it is discoverable.
* @property string $banner Banner hash.
* @property int $premium_tier Server boost level.
* @property int $premium_subscription_count Number of boosts in the guild.
* @property string $preferred_locale Preferred locale of the guild.
* @property string $public_updates_channel_id Notice channel id.
* @property int $max_video_channel_users Maximum amount of users allowed in a video channel.
* @property int $approximate_member_count
* @property int $approximate_presence_count
* @property bool $feature_animated_icon guild has access to set an animated guild icon.
* @property bool $feature_banner guild has access to set a guild banner image.
* @property bool $feature_commerce guild has access to use commerce features (create store channels).
* @property bool $feature_community guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates.
* @property bool $feature_discoverable guild is able to be discovered in the directory.
* @property bool $feature_featurable guild is able to be featured in the directory.
* @property bool $feature_invite_splash guild has access to set an invite splash background.
* @property bool $feature_member_verification_gate_enabled guild has enabled membership screening.
* @property bool $feature_news guild has access to create news channels.
* @property bool $feature_partnered guild is partnered.
* @property bool $feature_preview_enabled guild can be previewed before joining via membership screening or the directory.
* @property bool $feature_vanity_url guild has access to set a vanity url.
* @property bool $feature_verified guild is verified.
* @property bool $feature_vip_regions guild has access to set 384kbps bitrate in voice.
* @property bool $feature_welcome_screen_enabled guild has enabled the welcome screen.
* @property bool $feature_ticketed_events_enabled guild has enabled ticketed events.
* @property bool $feature_monetization_enabled guild has enabled monetization.
* @property bool $feature_more_stickers guild has increased custom sticker slots.
* @property bool $feature_three_day_thread_archive guild has access to the three day archive time for threads.
* @property bool $feature_seven_day_thread_archive guild has access to the seven day archive time for threads.
* @property bool $feature_private_threads guild has access to create private threads.
* @property RoleRepository $roles
* @property ChannelRepository $channels
* @property MemberRepository $members
Expand Down Expand Up @@ -136,6 +157,33 @@ class Guild extends Part
'approximate_presence_count',
];

/**
* @inheritDoc
*/
protected $visible = [
'feature_animated_icon',
'feature_banner',
'feature_commerce',
'feature_community',
'feature_discoverable',
'feature_featurable',
'feature_invite_splash',
'feature_member_verification_gate_enabled',
'feature_news',
'feature_partnered',
'feature_preview_enabled',
'feature_vanity_url',
'feature_verified',
'feature_vip_regions',
'feature_welcome_screen_enabled',
'feature_ticketed_events_enabled',
'feature_monetization_enabled',
'feature_more_stickers',
'feature_three_day_thread_archive',
'feature_seven_day_thread_archive',
'feature_private_threads',
];

/**
* @inheritdoc
*/
Expand Down Expand Up @@ -274,6 +322,106 @@ protected function getSplashHashAttribute()
return $this->attributes['splash'];
}

protected function getFeatureAnimatedIconAttribute(): bool
{
return in_array('ANIMATED_ICON', $this->features);
}

protected function getFeatureBannerAttribute(): bool
{
return in_array('BANNER', $this->features);
}

protected function getFeatureCommerceAttribute(): bool
{
return in_array('COMMERCE', $this->features);
}

protected function getFeatureDiscoverableAttribute(): bool
{
return in_array('DISCOVERABLE', $this->features);
}

protected function getFeatureFeaturableAttribute(): bool
{
return in_array('FEATURABLE', $this->features);
}

protected function getFeatureInviteSplashAttribute(): bool
{
return in_array('INVITE_SPLASH', $this->features);
}

protected function getFeatureMemberVerificationGateEnabledAttribute(): bool
{
return in_array('MEMBER_VERIFICATION_GATE_ENABLED', $this->features);
}

protected function getFeatureNewsAttribute(): bool
{
return in_array('NEWS', $this->features);
}

protected function getFeaturePartneredAttribute(): bool
{
return in_array('PARTNERED', $this->features);
}

protected function getFeaturePreviewEnabledAttribute(): bool
{
return in_array('PREVIEW_ENABLED', $this->features);
}

protected function getFeatureVanityUrlAttribute(): bool
{
return in_array('VANITY_URL', $this->features);
}

protected function getFeatureVerifiedAttribute(): bool
{
return in_array('VERIFIED', $this->features);
}

protected function getFeatureVipRegionsAttribute(): bool
{
return in_array('VIP_REGIONS', $this->features);
}

protected function getFeatureWelcomeScreenEnabledAttribute(): bool
{
return in_array('WELCOME_SCREEN_ENABLED', $this->features);
}

protected function getFeatureTicketedEventsEnabledAttribute(): bool
{
return in_array('TICKETED_EVENTS_ENABLED', $this->features);
}

protected function getFeatureMonetizationEnabledAttribute(): bool
{
return in_array('MONETIZATION_ENABLED', $this->features);
}

protected function getFeatureMoreStickersAttribute(): bool
{
return in_array('MORE_STICKERS', $this->features);
}

protected function getFeatureThreeDayThreadArchiveAttribute(): bool
{
return in_array('THREE_DAY_THREAD_ARCHIVE', $this->features);
}

protected function getFeatureSevenDayThreadArchiveAttribute(): bool
{
return in_array('SEVEN_DAY_THREAD_ARCHIVE', $this->features);
}

protected function getFeaturePrivateThreadsAttribute(): bool
{
return in_array('PRIVATE_THREADS', $this->features);
}

/**
* Gets the voice regions available.
*
Expand Down

0 comments on commit 7ce6256

Please sign in to comment.