1616use Discord \Parts \Guild \Emoji ;
1717use Discord \Parts \Guild \Guild ;
1818use Discord \Parts \Part ;
19+ use Discord \Parts \Thread \Thread ;
1920use Discord \Parts \User \User ;
2021use React \Promise \ExtendedPromiseInterface ;
22+ use stdClass ;
2123use Symfony \Component \OptionsResolver \OptionsResolver ;
2224
2325use function Discord \normalizePartId ;
@@ -49,6 +51,7 @@ class Reaction extends Part
4951 * {@inheritDoc}
5052 */
5153 protected $ fillable = [
54+ 'id ' , // internal
5255 'count ' ,
5356 'me ' ,
5457 'emoji ' ,
@@ -80,6 +83,42 @@ public function fetch(): ExtendedPromiseInterface
8083 });
8184 }
8285
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+
83122 /**
84123 * Gets the emoji identifier.
85124 *
@@ -101,7 +140,7 @@ protected function getIdAttribute(): string
101140 *
102141 * @link https://discord.com/developers/docs/resources/channel#get-reactions
103142 *
104- * @return ExtendedPromiseInterface<Collection|Users []>
143+ * @return ExtendedPromiseInterface<Collection|User []>
105144 */
106145 public function getUsers (array $ options = []): ExtendedPromiseInterface
107146 {
@@ -144,7 +183,7 @@ public function getUsers(array $options = []): ExtendedPromiseInterface
144183 *
145184 * @see Message::getUsers()
146185 *
147- * @return ExtendedPromiseInterface<Collection|Users []>
186+ * @return ExtendedPromiseInterface<Collection|User []>
148187 */
149188 public function getAllUsers (): ExtendedPromiseInterface
150189 {
0 commit comments