Skip to content

Commit

Permalink
Renamed $set to $patch
Browse files Browse the repository at this point in the history
  • Loading branch information
valzargaming authored Jun 23, 2024
1 parent f675991 commit 339f9d6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Discord/Parts/User/Member.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,14 @@ public function moveMember($channel, ?string $reason = null): ExtendedPromiseInt
*
* @param Role|string $role The role to add to the member.
* @param string|null $reason Reason for Audit Log.
* @param bool|null $set Whether to set the roles using PATCH instead of PUT and return the updated member part on resolved promise.
* @param bool|null $patch Whether to set the roles using PATCH instead of PUT and return the updated member part on resolved promise.
*
* @throws \RuntimeException
* @throws NoPermissionsException Missing manage_roles permission.
*
* @return ExtendedPromiseInterface|ExtendedPromiseInterface<static>
*/
public function addRole($role, ?string $reason = null, ?bool $set = false): ExtendedPromiseInterface
public function addRole($role, ?string $reason = null, ?bool $patch = false): ExtendedPromiseInterface
{
if ($role instanceof Role) {
$role = $role->id;
Expand All @@ -280,7 +280,7 @@ public function addRole($role, ?string $reason = null, ?bool $set = false): Exte
$headers['X-Audit-Log-Reason'] = $reason;
}

return $set
return $patch
? $this->http->patch(Endpoint::bind(Endpoint::GUILD_MEMBER, $this->guild_id, $this->id), ['roles' => array_merge($this->attributes['roles'], [$role])], $headers)
->then(function ($response) {
$this->attributes['roles'] = $response->roles;
Expand All @@ -302,13 +302,13 @@ public function addRole($role, ?string $reason = null, ?bool $set = false): Exte
*
* @param Role|string $role The role to remove from the member.
* @param string|null $reason Reason for Audit Log.
* @param bool|null $set Whether to set the roles using PATCH instead of DELETE and return the updated member part on resolved promise.
* @param bool|null $patch Whether to set the roles using PATCH instead of DELETE and return the updated member part on resolved promise.
*
* @throws NoPermissionsException Missing manage_roles permission.
*
* @return ExtendedPromiseInterface|ExtendedPromiseInterface<static>
*/
public function removeRole($role, ?string $reason = null, ?bool $set = false): ExtendedPromiseInterface
public function removeRole($role, ?string $reason = null, ?bool $patch = false): ExtendedPromiseInterface
{
if ($role instanceof Role) {
$role = $role->id;
Expand All @@ -327,7 +327,7 @@ public function removeRole($role, ?string $reason = null, ?bool $set = false): E
$headers['X-Audit-Log-Reason'] = $reason;
}

return $set
return $patch
? $this->http->patch(Endpoint::bind(Endpoint::GUILD_MEMBER, $this->guild_id, $this->id), ['roles' => array_diff($this->attributes['roles'], [$role])], $headers)
->then(function ($response) {
$this->attributes['roles'] = $response->roles;
Expand Down

0 comments on commit 339f9d6

Please sign in to comment.