Manager
in package
uses
EventEmitterTrait
FinalYes
Manages many voice clients for the bot.
Tags
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
= []
$discord
protected
Discord
$discord
$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
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|nulljoinChannel()
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_sessionsitself, through VoiceSessions. - $mute : bool = false
- $deaf : bool = true
Tags
Return values
PromiseInterfacestateUpdate()
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