Skip to content

Commit ed5c3c2

Browse files
committed
Create ResourceChannel.php
1 parent 5d3b8c0 commit ed5c3c2

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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\Parts\Channel\Channel;
18+
use Discord\Parts\Part;
19+
20+
/**
21+
* Resource channel in Home settings.
22+
*
23+
* @link https://github.com/discord/discord-api-spec/blob/7cba79e03a393456fc904cff470097d3be383bec/specs/openapi_preview.json#L34147
24+
*
25+
* @since 10.47.0 OpenAPI Preview
26+
*
27+
* @property string $channel_id The channel id for the resource.
28+
* @property string $title The title of the resource channel.
29+
* @property Emoji|null $emoji The partial emoji for the resource.
30+
* @property string|null $icon The icon string, if present.
31+
* @property string $description The description of the resource channel.
32+
*
33+
* @property-read string|null $guild_id The guild id associated with this resource channel.
34+
* @property-read Guild|null $guild The guild associated with this resource channel.
35+
* @property-read Channel|null $channel The channel associated with this resource channel.
36+
*/
37+
class ResourceChannel extends Part
38+
{
39+
/**
40+
* @inheritDoc
41+
*/
42+
protected $fillable = [
43+
'channel_id',
44+
'title',
45+
'emoji',
46+
'icon',
47+
'description',
48+
49+
// @internal
50+
'guild_id',
51+
];
52+
53+
/**
54+
* Gets the emoji.
55+
*
56+
* @return Emoji|null
57+
*/
58+
protected function getEmojiAttribute(): ?Emoji
59+
{
60+
return $this->attributePartHelper('emoji', Emoji::class);
61+
}
62+
63+
/**
64+
* Gets the guild.
65+
*
66+
* @return Guild|null
67+
*/
68+
protected function getGuildAttribute(): ?Guild
69+
{
70+
return $this->discord->guilds->get('id', $this->guild_id);
71+
}
72+
73+
/**
74+
* Gets the channel.
75+
*
76+
* @return Channel|null
77+
*/
78+
protected function getChannelAttribute(): ?Channel
79+
{
80+
return $this->discord->channels->get('id', $this->channel_id);
81+
}
82+
}

0 commit comments

Comments
 (0)