Skip to content

Conversation

@valzargaming
Copy link
Member

This pull request introduces support for the discord-php-helpers/voice package and updates the instantiation of the VoiceClient class to align with the new helper package's interface. The main focus is on integrating the new voice helper and simplifying the VoiceClient constructor usage.

Dependency update:

  • Added discord-php-helpers/voice as a dependency in composer.json to enable new voice-related features.

Voice client integration:

  • Updated the VoiceClient instantiation in Discord.php to use the new constructor signature, removing now-unnecessary parameters and aligning with the helper package's API.

@valzargaming valzargaming marked this pull request as ready for review December 8, 2025 05:36
@valzargaming
Copy link
Member Author

This PR will need to require the new DiscordPHP-Voice external repository until at least v11 to avoid introducing a breaking change.

@valzargaming valzargaming added important features dependencies Pull requests that update a dependency file labels Dec 8, 2025
@valzargaming valzargaming requested a review from a team December 8, 2025 05:53
Copy link
Contributor

@danielhe4rt danielhe4rt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank god for you adding docblocks everywhere around.

That is something that Rust has and after I saw it I really wanted to see more in PHP.

Left some comments, see if it make any sense.

Comment on lines +1413 to +1416
if (class_exists(Manager::class, false)) {
$this->voice = new Manager($this);
$this->logger->info('voice class initialized');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't a better approach? Since it's a 3rd party dependency, using the namespace directly on the "class_exists" method IMHO is a better standard.

Suggested change
if (class_exists(Manager::class, false)) {
$this->voice = new Manager($this);
$this->logger->info('voice class initialized');
}
if (class_exists(\Discord\Voice\Manager::class, false)) {
$this->voice = new Manager($this);
$this->logger->info('voice class initialized');
}

Copy link
Member Author

@valzargaming valzargaming Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manager class is added as an import at the top of the file, so this is effectively the same thing. To reduce redundancy there is no need to type out the entire namespace, and if it ever changed in the future it would then need to be updated in multiple places rather than just in the import.

The only reason this is now an external repo is because the voice API version can and will differ from the regular API version, and we want to have proper version control and guarantee things won't break for users who need to upgrade in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class is not 3rd party, it's also managed/maintained by us.

Comment on lines -1895 to +1903
static $allowed = ['loop', 'options', 'logger', 'http', 'application_commands', 'voice_sessions'];
static $allowed = ['loop', 'options', 'logger', 'http', 'application_commands'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What effectively changes here? What is the other way to get the voice_sessions?

Copy link
Member Author

@valzargaming valzargaming Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was originally made because I believed that simply getting it through the magic method was sufficient, however because it was a protected variable and was also needing to be modified attempting to do so would fail. This property is now public to resolve that, and also so it can be used in areas outside of the voice client where a user may just want to know what voice sessions are active without needing the client to be processing voice data. For example, an interaction on a message that should only be usable by users who are in a voice call with the bot.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's going to be within the voice package i believe.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, it is used for voice session management. If one already exists we need to use the existing session, otherwise we need to manage a new one.

If we overwrite it we won't get useful data logged in the first warning
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement features important voice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants