# DiscordVoiceSession

### Inherits from

{% content-ref url="/pages/-MJ8DHAgbUXLYo2Y0pSA" %}
[DiscordMediaSession](/anarchy/documentation/media-sessions/discordmediasession.md)
{% endcontent-ref %}

## Events

| Name               | Description                                                                |
| ------------------ | -------------------------------------------------------------------------- |
| OnConnected        | Fired when the client has connected and authenticated to the server        |
| OnDisconnected     | Fired when the client is forcefully disconnected or Disconnect() is called |
| OnUserConnected    | Fired when a user connects to the voice channel                            |
| OnUserDisconnected | Fired when a user leaves the voice channel                                 |
| OnUserSpeaking     | Fired when a user starts speaking                                          |
| OnChannelChanged   | Triggered whenever the user is moved into another channel                  |

## Properties

| Name       | Description                                        | Type                                 |
| ---------- | -------------------------------------------------- | ------------------------------------ |
| Speaking   | True if the client is sending voice data           | bool                                 |
| Livestream | A reference to the Go Live created by the client   | DiscordGoLiveSession?                |
| Watching   | A reference to the Go Lives the client is watching | IReadOnlyList\<DiscordGoLiveSession> |

## Methods

### SetSpeakingState

Sets the client's speaking flags.

#### Parameters

| Name  | Description        | Type                 |
| ----- | ------------------ | -------------------- |
| flags | The speaking flags | DiscordSpeakingFlags |

### GoLive

Starts a Go Live session. This will set Livestream.

#### Returns

{% content-ref url="/pages/-MJ8HM\_8cZ0b5ZQEzWb4" %}
[DiscordGoLiveSession](/anarchy/documentation/media-sessions/go-live-sessions/discordgolivesession.md)
{% endcontent-ref %}

### WatchGoLive

Connects to another user's Go Live. This will add a stream to Watching.

#### Parameters

| Name   | Description                                  | Type  |
| ------ | -------------------------------------------- | ----- |
| userId | The ID of the user who's livestream to watch | ulong |

#### Returns

{% content-ref url="/pages/-MJ8HM\_8cZ0b5ZQEzWb4" %}
[DiscordGoLiveSession](/anarchy/documentation/media-sessions/go-live-sessions/discordgolivesession.md)
{% endcontent-ref %}

### CreateStream

Creates a voice stream which you can send data through to speak.

#### Parameters

| Name        | Description                                                                         | Type              |
| ----------- | ----------------------------------------------------------------------------------- | ----------------- |
| bitrate     | The bitrate at which to send data through. Values between 5000 and 384000 are valid | int               |
| application | Lets you optimize the encoder for a specific type of audio                          | AudioApplication? |

#### Returns

{% content-ref url="/pages/-MJCPzv-LlAxMcf1E0pN" %}
[DiscordVoiceStream](/anarchy/documentation/media-sessions/voice-sessions/discordvoicestream.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ilinked1337.gitbook.io/anarchy/documentation/media-sessions/voice-sessions/discordvoicesession.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
