# Leave a Voice Channel

<figure><img src="/files/IgRBgaTV7b96fBCtflhl" alt=""><figcaption></figcaption></figure>

The Leave a Voice Channel action block will force the bot to leave the channel it is connected in, optionally specifying the server ID.

{% hint style="warning" %}
Keep in mind the bot has to be in a voice channel for this block to work
{% endhint %}

## Optional Server ID

This action block contains one setting: Optional Server ID.

Having a server ID in this field will force the bot to look for a specific server to leave from. Leaving this blank will force the bot to leave the voice channel in the server the command / event was triggered in or [button](/custom-commands-and-events/actions/legacy-reply-actions/send-a-message-with-attached-buttons/buttons.md) / [menu option](/custom-commands-and-events/actions/legacy-reply-actions/send-a-message-with-a-select-menu/menu-option.md).

<figure><img src="/files/taK562hfnXLU2KoBGvkh" alt=""><figcaption></figcaption></figure>

## Enable Success/Error Handles

Enable Success / Error Handles to detect success and errors inside of the action block. This allows you to run different actions if something goes wrong with your action. Inside of the handle, there are 2 different paths which are used to detect the outcome of the action. The green path on the bottom left side of the block indicates success, while the red path on the bottom right side of the block indicates error. You may attach action blocks to each side of the handle to get the outcome of your action block.

<figure><img src="/files/pYtBPljHi13YFv89blSF" alt=""><figcaption></figcaption></figure>

The Success/Error Handles feature includes 3 different error variables you can use to get information on why the action block encountered an error. Check them out [here](/custom-commands-and-events/variables.md#error-variables).

<figure><img src="/files/Z6BMojtNrGm08e6s9BHp" alt=""><figcaption></figcaption></figure>


---

# 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://documentation.botghost.com/custom-commands-and-events/actions/voice-actions/leave-a-voice-channel.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.
