# voice

> `const` **voice**: `object`

Defined in: [sdk/js/src/voice.ts:35](https://github.com/zaunchat/zaun-bot/blob/main/sdk/js/src/voice.ts#L35)

The bot's voice stay and player. Errors throw `ZaunError` (`FORBIDDEN` without grants).

## Type Declaration

### clearQueue()

> **clearQueue**(): `void`

Empties the queue; unlike `stop`, the current track keeps playing.

#### Returns

`void`

### endStream()

> **endStream**(): `void`

The `pushed` track ends once its buffer has played.

#### Returns

`void`

### enqueue()

> **enqueue**(`t`): `number`

Adds to the queue (≤ 100); returns its length.

#### Parameters

##### t

`string` \| [`TrackOptions`](/docs/reference/js/zaun-bot/type-aliases/trackoptions/)

#### Returns

`number`

### join()

> **join**(`channelId`): `void`

Joins a voice channel (leaving another first); returns once audio can flow.

#### Parameters

##### channelId

`string`

#### Returns

`void`

### leave()

> **leave**(): `void`

Leaves; playback stops and the queue clears.

#### Returns

`void`

### moveTrack()

> **moveTrack**(`from`, `to`): `void`

Moves the queued track at `from` to `to` (both 0-based); the tracks between shift.

#### Parameters

##### from

`number`

##### to

`number`

#### Returns

`void`

### pause()

> **pause**(): `void`

#### Returns

`void`

### play()

> **play**(`t`): `void`

Plays now, replacing the current track (a string is a URL).

#### Parameters

##### t

`string` \| [`TrackOptions`](/docs/reference/js/zaun-bot/type-aliases/trackoptions/)

#### Returns

`void`

### push()

> **push**(`packets`): `number`

Opus packets for the current `pushed` track; returns ms buffered (`BUSY` past 3 s).

#### Parameters

##### packets

`Uint8Array`\<`ArrayBufferLike`\>[]

#### Returns

`number`

### remove()

> **remove**(`index`): `string`

Removes the queued track at `index` (0 plays next); returns its title. Throws `NOT_FOUND`
past the end. Like every queue call, `UNSUPPORTED` on hosts without queue control.

#### Parameters

##### index

`number`

#### Returns

`string`

### resume()

> **resume**(): `void`

#### Returns

`void`

### seek()

> **seek**(`ms`): `void`

Jumps to `ms` into the current track; past the end, the track ends. Throws `UNSUPPORTED` for
live streams and pushed audio, and on hosts that cannot seek; `CONFLICT` when nothing plays.

#### Parameters

##### ms

`number`

#### Returns

`void`

### setLoop()

> **setLoop**(`mode`): `void`

Sets what happens when a track ends.

#### Parameters

##### mode

`LoopMode`

#### Returns

`void`

### setVolume()

> **setVolume**(`percent`): `void`

Sets the playback volume, 0–200 % (100 when the bot joins). Throws `ZaunError` `BAD_REQUEST`
(detail `percent`) outside 0–200, checked before the call, and `UNSUPPORTED` on hosts without
an Opus encoder, which is most of them for now: tell the member and go on.

#### Parameters

##### percent

`number`

#### Returns

`void`

### shuffle()

> **shuffle**(): `void`

Puts the queue in a random order; the current track keeps playing.

#### Returns

`void`

### skip()

> **skip**(): `void`

#### Returns

`void`

### state()

> **state**(): [`VoiceState`](/docs/reference/js/zaun-bot/type-aliases/voicestate/)

#### Returns

[`VoiceState`](/docs/reference/js/zaun-bot/type-aliases/voicestate/)

### stop()

> **stop**(): `void`

Ends the current track and clears the queue.

#### Returns

`void`
