DiscordPHP-Voice Documentation

Manager
in package
uses EventEmitterTrait

FinalYes

Manages many voice clients for the bot.

Tags
requires

libopus - Linux | NOT TESTED - WINDOWS

FFMPEG - Linux | NOT TESTED - WINDOWS

libdave

since
10.19.0

Table of Contents

Properties

$clients  : array<string|int, mixed>
$discord  : Discord
$serverListeners  : array<string, Closure>
$stateListeners  : array<string, Closure>
Listener references keyed by guild ID for cleanup.

Methods

__construct()  : mixed
getClient()  : Client|null
Retrieves the voice client for a given guild id.
joinChannel()  : PromiseInterface
Handles the creation of a new voice client and joins the specified channel.
stateUpdate()  : void
Handles the voice state update event to update session information for the voice client.
serverUpdate()  : void
Handles the voice server update event to create a new voice client with the provided state.
removeAllListeners()  : void
Removes all gateway listeners for a guild.
removeServerListener()  : void
Removes the server update listener for a guild, if registered.

Properties

$clients

public array<string|int, mixed> $clients = []

$serverListeners

private array<string, Closure> $serverListeners = []

$stateListeners

Listener references keyed by guild ID for cleanup.

private array<string, Closure> $stateListeners = []

Methods

__construct()

public __construct(Discord $discord[, array<string, Client> $clients = [] ]) : mixed
Parameters
$discord : Discord
$clients : array<string, Client> = []
Tags
throws
LibDaveNotFoundException

if libdave is not available

getClient()

Retrieves the voice client for a given guild id.

public getClient(string|int|Channel $guildChannelOrId) : Client|null
Parameters
$guildChannelOrId : string|int|Channel
Return values
Client|null

joinChannel()

Handles the creation of a new voice client and joins the specified channel.

public joinChannel(Channel $channel[, Discord|null $discord = null ][, array<string|int, mixed>|AbstractRepository|null $voice_sessions = null ][, bool $mute = false ][, bool $deaf = true ]) : PromiseInterface
Parameters
$channel : Channel
$discord : Discord|null = null

Defaults to the client this manager was constructed with.

$voice_sessions : array<string|int, mixed>|AbstractRepository|null = null

$discord->voice_sessions, handed to the voice client as given. Sessions are read from $discord->voice_sessions itself, through VoiceSessions.

$mute : bool = false
$deaf : bool = true
Tags
throws
ChannelMustAllowVoiceException
EnterChannelDeniedException
CantJoinMoreThanOneChannelException
CantSpeakInChannelException
since
8.3.0

$voice_sessions is no longer taken by reference, and may be DiscordPHP's voice session repository.

8.3.0

$discord is optional, so $discord->voice->joinChannel($channel) works.

Return values
PromiseInterface

stateUpdate()

Handles the voice state update event to update session information for the voice client.

public stateUpdate(VoiceStateUpdate $state, Channel $channel) : void
Parameters
$state : VoiceStateUpdate
$channel : Channel

serverUpdate()

Handles the voice server update event to create a new voice client with the provided state.

protected serverUpdate(VoiceServerUpdate $state, Channel $channel, Discord $discord, Deferred $deferred) : void
Parameters
$state : VoiceServerUpdate
$channel : Channel
$discord : Discord
$deferred : Deferred

removeAllListeners()

Removes all gateway listeners for a guild.

private removeAllListeners(string|int $guildId) : void
Parameters
$guildId : string|int

removeServerListener()

Removes the server update listener for a guild, if registered.

private removeServerListener(string|int $guildId) : void
Parameters
$guildId : string|int
On this page

Search results