Skip to content

Commit 113f3d0

Browse files
committed
Replace calls to voiceClients array
1 parent eaaea98 commit 113f3d0

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/Discord/Discord.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,6 @@ class Discord
209209
*/
210210
protected $sessionId;
211211

212-
/**
213-
* An array of voice clients that are currently connected.
214-
*
215-
* @var VoiceClient[] Voice Clients.
216-
*/
217-
public array $voiceClients = [];
218-
219212
/**
220213
* An array of guild IDs paired to their voice session IDs.
221214
*
@@ -461,9 +454,9 @@ public function __construct(array $options = [])
461454
*/
462455
protected function handleVoiceServerUpdate(object $data): void
463456
{
464-
if (isset($this->voiceClients[$data->d->guild_id])) {
457+
if (isset($this->voice->clients[$data->d->guild_id])) {
465458
$this->logger->debug('voice server update received', ['guild' => $data->d->guild_id, 'data' => $data->d]);
466-
$this->voiceClients[$data->d->guild_id]->handleVoiceServerChange((array) $data->d);
459+
$this->voice->clients[$data->d->guild_id]->handleVoiceServerChange((array) $data->d);
467460
}
468461
}
469462

@@ -1461,7 +1454,7 @@ public function listVoiceRegions(): PromiseInterface
14611454
*/
14621455
public function getVoiceClient(string $guild_id): ?VoiceClient
14631456
{
1464-
return $this->voiceClients[$guild_id] ?? null;
1457+
return $this->voice->clients[$guild_id] ?? null;
14651458
}
14661459

14671460
/**
@@ -1526,7 +1519,7 @@ protected function voiceServerUpdate(VoiceServerUpdate $vs, Channel $channel, ar
15261519
$data['dnsConfig'] = $this->options['dnsConfig'];
15271520
$this->logger->info('received token and endpoint for voice session', ['guild' => $channel->guild_id, 'token' => $vs->token, 'endpoint' => $vs->endpoint]);
15281521

1529-
$this->voiceClients[$channel->guild_id] ??= $vc = $this->voiceClients[$channel->guild_id] ?? new VoiceClient($this, $channel, $this->voice_sessions, $data, deferred: $deferred, manager: $this->voice);
1522+
$this->voice->clients[$channel->guild_id] ??= $vc = $this->voice->clients[$channel->guild_id] ?? new VoiceClient($this, $channel, $this->voice_sessions, $data, deferred: $deferred, manager: $this->voice);
15301523

15311524
$vc->once('ready', function () use ($vc, $deferred) {
15321525
$this->logger->info('voice client is ready');
@@ -1538,7 +1531,7 @@ protected function voiceServerUpdate(VoiceServerUpdate $vs, Channel $channel, ar
15381531
});
15391532
$vc->once('close', function () use ($channel) {
15401533
$this->logger->warning('voice client closed');
1541-
unset($this->voiceClients[$channel->guild_id]);
1534+
unset($this->voice->clients[$channel->guild_id]);
15421535
});
15431536

15441537
$vc->setData(

0 commit comments

Comments
 (0)