|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is a part of the DiscordPHP project. |
| 7 | + * |
| 8 | + * Copyright (c) 2015-2022 David Cole <david.cole1340@gmail.com> |
| 9 | + * Copyright (c) 2020-present Valithor Obsidion <valithor@discordphp.org> |
| 10 | + * |
| 11 | + * This file is subject to the MIT license that is bundled |
| 12 | + * with this source code in the LICENSE.md file. |
| 13 | + */ |
| 14 | + |
| 15 | +namespace Discord\Parts\Guild; |
| 16 | + |
| 17 | +use Discord\Helpers\ExCollectionInterface; |
| 18 | +use Discord\Parts\Part; |
| 19 | + |
| 20 | +/** |
| 21 | + * Home Settings for a guild. |
| 22 | + * |
| 23 | + * @link https://github.com/discord/discord-api-spec/blob/7cba79e03a393456fc904cff470097d3be383bec/specs/openapi_preview.json#L25369 |
| 24 | + * |
| 25 | + * @since 10.47.0 OpenAPI Preview |
| 26 | + * |
| 27 | + * @property string $guild_id The guild (server) id. |
| 28 | + * @property bool $enabled Whether Home is enabled for the guild. |
| 29 | + * @property WelcomeMessage|null $welcome_message The welcome message settings. |
| 30 | + * @property ExCollectionInterface<NewMemberAction>|NewMemberAction[] $new_member_actions The new member actions. |
| 31 | + * @property ExCollectionInterface<ResourceChannel>|ResourceChannel[] $resource_channels The resource channels. |
| 32 | + * |
| 33 | + * @property-read Guild|null $guild The guild associated with these Home settings. |
| 34 | + */ |
| 35 | +class HomeSettings extends Part |
| 36 | +{ |
| 37 | + /** |
| 38 | + * @inheritDoc |
| 39 | + */ |
| 40 | + protected $fillable = [ |
| 41 | + 'guild_id', |
| 42 | + 'enabled', |
| 43 | + 'welcome_message', |
| 44 | + 'new_member_actions', |
| 45 | + 'resource_channels', |
| 46 | + ]; |
| 47 | + |
| 48 | + /** |
| 49 | + * Gets the welcome message. |
| 50 | + * |
| 51 | + * @return WelcomeMessage|null |
| 52 | + */ |
| 53 | + protected function getWelcomeMessageAttribute(): ?WelcomeMessage |
| 54 | + { |
| 55 | + return $this->attributePartHelper('welcome_message', WelcomeMessage::class); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Gets the new member actions. |
| 60 | + * |
| 61 | + * @return ExCollectionInterface<NewMemberAction> |
| 62 | + */ |
| 63 | + protected function getNewMemberActionsAttribute(): ExCollectionInterface |
| 64 | + { |
| 65 | + return $this->attributeCollectionHelper('new_member_actions', NewMemberAction::class, 'id', ['guild_id' => $this->guild_id]); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Gets the resource channels. |
| 70 | + * |
| 71 | + * @return ExCollectionInterface<ResourceChannel> |
| 72 | + */ |
| 73 | + protected function getResourceChannelsAttribute(): ExCollectionInterface |
| 74 | + { |
| 75 | + return $this->attributeCollectionHelper('resource_channels', ResourceChannel::class, 'channel_id', ['guild_id' => $this->guild_id]); |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * Gets the guild. |
| 80 | + * |
| 81 | + * @return Guild|null |
| 82 | + */ |
| 83 | + protected function getGuildAttribute(): ?Guild |
| 84 | + { |
| 85 | + return $this->discord->guilds->get('id', $this->guild_id); |
| 86 | + } |
| 87 | +} |
0 commit comments