Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Discord/Parts/Embed/EmbedPollResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
);

Expand Down
43 changes: 43 additions & 0 deletions src/Discord/Parts/User/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<self>
*/
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.
*
Expand Down