AudioPlayerAPI: Fix Options. (#1166)

* Fix Options.

* Cleanup.

* Better Anchor.

* Even Better Anchor.

* Even Better Anchor v2.
This commit is contained in:
Etorix 2026-06-11 05:49:27 -07:00 • committed by GitHub
parent 98ebb1eaa1
commit 02b56940cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 4 deletions

View file

@ -184,11 +184,11 @@ export function createAudioPlayer(
options: AudioPlayerOptions = {}
): AudioPlayerInterface {
const internalPlayer: AudioPlayerInternal = new AudioPlayerConstructor(
options,
audio,
null,
null,
"default",
options
"default"
);
return new AudioPlayerWrapper(internalPlayer);

View file

@ -31,8 +31,8 @@ export default definePlugin({
// Adds an optional persistent boolean as well as a callback and error handler to the
// audio player which is called after the audio finishes playing and when an error occurs.
// Also processes the audio before playing to apply override functions set by plugins.
match: /(?<=constructor\(([^)]+))\)[^}]+/,
replace: ",options){$self.buildPlayer(this,options,$1);"
match: /constructor\(((?:\i,){3}\i)([^)]*)\)\{[^}]+}/,
replace: "constructor(options,$1$2){$self.buildPlayer(this,options,$1);}"
},
{
// Prevents an error from the source being cleared during destroyAudio().
@ -66,6 +66,14 @@ export default definePlugin({
}
]
},
{
// Pass undefined for options in default Discord calls to the audio constructor.
find: "SoundUtils",
replacement: {
match: /return new (\i)\((.{0,50}?)(?=}function)/,
replace: "return new $1(undefined,$2"
}
},
{
// Prevents Discord from forcing full volume for the "discodo" effect on client load.
// The internal sounds module being loaded on startup relies on one of these calls to volume