Method UpdateVoiceStateAsync
| Improve this Doc View SourceUpdateVoiceStateAsync(Snowflake, Snowflake?, bool, bool, CancellationToken?)
Joins, moves, or disconnects the application from a voice channel.
Declaration
Task UpdateVoiceStateAsync(Snowflake guildId, Snowflake? channelId, bool isMute = false, bool isDeaf = false, CancellationToken? cancellationToken = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Snowflake | guildId | The ID of the guild containing the voice channel. An application can only be in one voice channel at a time per guild. |
| Snowflake? | channelId | The ID of the voice channel to join/move to or null to disconnect from voice. |
| bool | isMute | Whether the application is self-mute. |
| bool | isDeaf | Whether the application is self-deafened. |
| CancellationToken? | cancellationToken | A token used to cancel the request. |
Returns
| Type | Description |
|---|---|
| Task |
Remarks
Normally, this method does not need to be called directly as DiscordVoiceConnections will call this for you.
An application can only be in one voice channel at a time per guild. This method will wait until the underlying Gateway connection is ready as well as retry if the connection closes unexpectedly until the given cancellation token is cancelled or the Gateway's shard is stopped.Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if the Gateway's shard has not been fully started. |
| ObjectDisposedException | Thrown if the Gateway's shard has been disposed. |
| OperationCanceledException | Thrown if the cancellation token is cancelled or the Gateway's shard is stopped while sending. |