diff --git a/src/Discord/Parts/Embed/EmbedPollResult.php b/src/Discord/Parts/Embed/EmbedPollResult.php index 489a32968..05a7500db 100644 --- a/src/Discord/Parts/Embed/EmbedPollResult.php +++ b/src/Discord/Parts/Embed/EmbedPollResult.php @@ -32,13 +32,13 @@ * @property ExCollectionInterface|Field[] $fields A collection of embed fields (max of 25). * @property-read array $poll_fields A collection of poll fields. * @property-read string|null $poll_fields['poll_question_text'] Question text from the original poll - * @property-read int|null $poll_fields['victor_answer_votes'] Number of votes for the answer(s) with the most votes - * @property-read int|null $poll_fields['total_votes'] Total number of votes in the poll - * @property-read ?string|null $poll_fields['victor_answer_id'] ID for the winning answer (optional) - * @property-read ?string|null $poll_fields['victor_answer_text'] Text for the winning answer (optional) - * @property-read ?string|null $poll_fields['victor_answer_emoji_id'] ID for an emoji associated with the winning answer (optional) - * @property-read ?string|null $poll_fields['victor_answer_emoji_name'] Name of an emoji associated with the winning answer (optional) - * @property-read ?bool|null $poll_fields['victor_answer_emoji_animated'] If an emoji associated with the winning answer is animated (optional) + * @property-read int|null $poll_fields['victor_answer_votes'] Number of votes for the answer(s) with the most votes + * @property-read int|null $poll_fields['total_votes'] Total number of votes in the poll + * @property-read ?string|null $poll_fields['victor_answer_id'] ID for the winning answer (optional) + * @property-read ?string|null $poll_fields['victor_answer_text'] Text for the winning answer (optional) + * @property-read ?string|null $poll_fields['victor_answer_emoji_id'] ID for an emoji associated with the winning answer (optional) + * @property-read ?string|null $poll_fields['victor_answer_emoji_name'] Name of an emoji associated with the winning answer (optional) + * @property-read ?bool|null $poll_fields['victor_answer_emoji_animated'] If an emoji associated with the winning answer is animated (optional) */ class EmbedPollResult extends Embed { @@ -54,7 +54,7 @@ protected function getPollFieldsAttribute(): array $fields = array_filter( $this->attributes['fields'] ?? [], - fn($key) => !in_array($key, ['name', 'value', 'inline']), + fn ($key) => ! in_array($key, ['name', 'value', 'inline']), ARRAY_FILTER_USE_KEY ); diff --git a/src/Discord/Parts/User/Member.php b/src/Discord/Parts/User/Member.php index 6e939d8a9..d78d84053 100644 --- a/src/Discord/Parts/User/Member.php +++ b/src/Discord/Parts/User/Member.php @@ -198,6 +198,49 @@ public function kick(?string $reason = null): PromiseInterface }); } + /** + * Modifies the current member (no validation). + * + * @link https://discord.com/developers/docs/resources/guild#modify-current-member-json-params + * + * @since 10.19.0 + * + * @param array $params The parameters to modify. + * @param ?string|null $params['nick'] Value to set user's nickname to. + * @param ?string|null $params['banner'] Data URI base64 encoded banner image. + * @param ?string|null $params['avatar'] Data URL base64 encoded avatar image. + * @param ?string|null $params['bio'] Guild member bio. + * @param string|null $reason Reason for Audit Log. + * + * @throws NoPermissionsException Member is not the current user. + * + * @return PromiseInterface + */ + public function modifyCurrentMember(array $params, ?string $reason = null): PromiseInterface + { + if ($this->discord->id != $this->id) { + return reject(new NoPermissionsException('You can only modify the current member.')); + } + + $allowed = ['nick', 'banner', 'avatar', 'bio']; + $params = array_filter( + $params, + fn ($key) => in_array($key, $allowed, true), + ARRAY_FILTER_USE_KEY + ); + + if (empty($params)) { + return reject(new \InvalidArgumentException('No valid parameters to modify.')); + } + + $headers = []; + if (isset($reason)) { + $headers['X-Audit-Log-Reason'] = $reason; + } + + return $this->http->patch(Endpoint::bind(Endpoint::GUILD_MEMBER_SELF, $this->guild_id), $params, $headers); + } + /** * Sets the nickname of the member. *