Skip to content

Commit 043d2a7

Browse files
committed
Create NewMemberAction.php
1 parent 1385ba7 commit 043d2a7

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
* An action taken for a new member in the welcome message.
22+
*
23+
* @link https://github.com/discord/discord-api-spec/blob/7cba79e03a393456fc904cff470097d3be383bec/specs/openapi_preview.json#L32111
24+
*
25+
* @since 10.47.0 OpenAPI Preview
26+
*
27+
* @property string|null $channel_id The target channel id.
28+
* @property int $action_type The action type (0 = VIEW, 1 = TALK).
29+
* @property string $title The action title.
30+
* @property string $description The action description.
31+
* @property Emoji|null $emoji The emoji associated with the action.
32+
* @property string|null $icon The icon string, if present.
33+
*
34+
* @property-read string|null $guild_id The guild id associated with this action.
35+
* @property-read Guild|null $guild The guild associated with this action.
36+
* @property-read Channel|null $channel The channel associated with this action.
37+
*/
38+
class NewMemberAction extends Part
39+
{
40+
public const ACTION_TYPE_VIEW = 0;
41+
public const ACTION_TYPE_TALK = 1;
42+
43+
/**
44+
* @inheritDoc
45+
*/
46+
protected $fillable = [
47+
'channel_id',
48+
'action_type',
49+
'title',
50+
'description',
51+
'emoji',
52+
'icon',
53+
54+
// @internal
55+
'guild_id',
56+
];
57+
58+
/**
59+
* Gets the emoji.
60+
*
61+
* @return Emoji|null
62+
*/
63+
protected function getEmojiAttribute(): ?Emoji
64+
{
65+
return $this->attributePartHelper('emoji', Emoji::class);
66+
}
67+
68+
/**
69+
* Gets the guild.
70+
*
71+
* @return Guild|null
72+
*/
73+
protected function getGuildAttribute(): ?Guild
74+
{
75+
return $this->discord->guilds->get('id', $this->guild_id);
76+
}
77+
78+
/**
79+
* Gets the channel.
80+
*
81+
* @return Channel|null
82+
*/
83+
protected function getChannelAttribute(): ?Channel
84+
{
85+
return $this->discord->channels->get('id', $this->attributes['channel_id']);
86+
}
87+
}

0 commit comments

Comments
 (0)