From f76e0f369de6e6a404e7dbcd51d60f19b6b89957 Mon Sep 17 00:00:00 2001 From: Valithor Obsidion Date: Fri, 17 Jan 2025 13:25:24 -0500 Subject: [PATCH] `setDeaf` and `setMute` on Member --- src/Discord/Parts/User/Member.php | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/Discord/Parts/User/Member.php b/src/Discord/Parts/User/Member.php index cdf2088e7..2500b6723 100644 --- a/src/Discord/Parts/User/Member.php +++ b/src/Discord/Parts/User/Member.php @@ -219,6 +219,42 @@ public function setNickname(?string $nick = null, ?string $reason = null): Promi }); } + public function setDeaf(bool $deaf, ?string $reason = null): PromiseInterface + { + if ($guild = $this->guild) { + if ($botperms = $guild->getBotPermissions()) { + if (! $botperms->deafen_members) { + return reject(new NoPermissionsException("You do not have permission to deafen members in the guild {$guild->id}.")); + } + } + } + + $headers = []; + if (isset($reason)) { + $headers['X-Audit-Log-Reason'] = $reason; + } + + return $this->http->patch(Endpoint::bind(Endpoint::GUILD_MEMBER, $this->guild_id, $this->id), ['deaf' => $deaf], $headers); + } + + public function setMute(bool $mute, ?string $reason = null): PromiseInterface + { + if ($guild = $this->guild) { + if ($botperms = $guild->getBotPermissions()) { + if (! $botperms->mute_members) { + return reject(new NoPermissionsException("You do not have permission to mute members in the guild {$guild->id}.")); + } + } + } + + $headers = []; + if (isset($reason)) { + $headers['X-Audit-Log-Reason'] = $reason; + } + + return $this->http->patch(Endpoint::bind(Endpoint::GUILD_MEMBER, $this->guild_id, $this->id), ['mute' => $mute], $headers); + } + /** * Moves the member to another voice channel. *