diff --git a/src/Discord/Discord.php b/src/Discord/Discord.php index 0da3bfdab..67244c1fb 100644 --- a/src/Discord/Discord.php +++ b/src/Discord/Discord.php @@ -1255,6 +1255,39 @@ protected function ready() } } + /** + * Updates the client's voice state in a guild. + * + * @param Guild|string $guild_id ID of the guild. + * @param Channel|string|null $channel_id ID of the voice channel to join, or null to disconnect. + * @param bool $self_mute Whether the client is muted. + * @param bool $self_deaf Whether the client is deafened. + * + * @since 10.19.0 + */ + public function updateVoiceState($guild_id, $channel_id = null, bool $self_mute = false, bool $self_deaf = false): void + { + if (! is_string($guild_id)) { + $guild_id = $guild_id->id; + } + + if (isset($channel_id) && ! is_string($channel_id)) { + $channel_id = $channel_id->id; + } + + $payload = Payload::new( + Op::OP_UPDATE_VOICE_STATE, + [ + 'guild_id' => $guild_id, + 'channel_id' => $channel_id, + 'self_mute' => $self_mute, + 'self_deaf' => $self_deaf, + ] + ); + + $this->send($payload); + } + /** * Updates the clients presence. * @@ -1287,7 +1320,7 @@ public function updatePresence(?Activity $activity = null, bool $idle = false, s } $payload = Payload::new( - Op::OP_PRESENCE_UPDATE, + Op::OP_UPDATE_PRESENCE, [ 'since' => $idle, 'activities' => [$activity],