16
16
use Discord \Parts \Guild \Emoji ;
17
17
use Discord \Parts \Guild \Guild ;
18
18
use Discord \Parts \Part ;
19
+ use Discord \Parts \Thread \Thread ;
19
20
use Discord \Parts \User \User ;
20
21
use React \Promise \ExtendedPromiseInterface ;
22
+ use stdClass ;
21
23
use Symfony \Component \OptionsResolver \OptionsResolver ;
22
24
23
25
use function Discord \normalizePartId ;
@@ -49,6 +51,7 @@ class Reaction extends Part
49
51
* {@inheritDoc}
50
52
*/
51
53
protected $ fillable = [
54
+ 'id ' , // internal
52
55
'count ' ,
53
56
'me ' ,
54
57
'emoji ' ,
@@ -80,6 +83,42 @@ public function fetch(): ExtendedPromiseInterface
80
83
});
81
84
}
82
85
86
+ /**
87
+ * Sets the emoji identifier.
88
+ *
89
+ * @internal Used for ReactionRepository::fetch()
90
+ *
91
+ * @param string $value name:id or the character of standard emoji
92
+ *
93
+ * @return void
94
+ *
95
+ * @since 10.0.0
96
+ */
97
+ protected function setIdAttribute (string $ value ): void
98
+ {
99
+ if (! isset ($ this ->attributes ['emoji ' ])) {
100
+ $ this ->attributes ['emoji ' ] = new stdClass ;
101
+ }
102
+
103
+ $ colonDelimiter = explode (': ' , $ value );
104
+ $ delimitedCount = count ($ colonDelimiter );
105
+ $ emojiId = $ emojiAnimated = null ;
106
+
107
+ if ($ delimitedCount == 2 ) { // Custom emoji name:id
108
+ [$ emojiName , $ emojiId ] = $ colonDelimiter ;
109
+ } elseif ($ delimitedCount == 3 ) { // Custom animated emoji a:name:id
110
+ [$ emojiAnimated , $ emojiName , $ emojiId ] = $ colonDelimiter ;
111
+ } else { // Standard emoji (or just have abnormal colon count)
112
+ $ emojiName = $ value ;
113
+ }
114
+
115
+ $ this ->attributes ['emoji ' ]->id = $ emojiId ;
116
+ $ this ->attributes ['emoji ' ]->name = $ emojiName ;
117
+ if ($ emojiAnimated == 'a ' ) {
118
+ $ this ->attributes ['emoji ' ]->animated = true ;
119
+ }
120
+ }
121
+
83
122
/**
84
123
* Gets the emoji identifier.
85
124
*
@@ -101,7 +140,7 @@ protected function getIdAttribute(): string
101
140
*
102
141
* @link https://discord.com/developers/docs/resources/channel#get-reactions
103
142
*
104
- * @return ExtendedPromiseInterface<Collection|Users []>
143
+ * @return ExtendedPromiseInterface<Collection|User []>
105
144
*/
106
145
public function getUsers (array $ options = []): ExtendedPromiseInterface
107
146
{
@@ -144,7 +183,7 @@ public function getUsers(array $options = []): ExtendedPromiseInterface
144
183
*
145
184
* @see Message::getUsers()
146
185
*
147
- * @return ExtendedPromiseInterface<Collection|Users []>
186
+ * @return ExtendedPromiseInterface<Collection|User []>
148
187
*/
149
188
public function getAllUsers (): ExtendedPromiseInterface
150
189
{
0 commit comments