fix(BaseClient): Prevent user agent mutation (#9425)

fix(BaseClient): prevent user agent mutation
This commit is contained in:
Jiralite
2023-04-28 18:46:50 +01:00
committed by GitHub
parent 40d07fbbbd
commit 217e5d8100

View File

@@ -18,17 +18,19 @@ class BaseClient extends EventEmitter {
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
}
if (options.rest?.userAgentAppendix) {
// Merging the default options when a custom user agent appendix is supplied
// Replaces the discord.js string. Enforce it.
options.rest.userAgentAppendix = `${Options.userAgentAppendix} ${options.rest.userAgentAppendix}`;
}
/**
* The options the client was instantiated with
* @type {ClientOptions}
*/
this.options = mergeDefault(Options.createDefault(), options);
this.options = mergeDefault(Options.createDefault(), {
...options,
rest: {
...options.rest,
userAgentAppendix: options.rest?.userAgentAppendix
? `${Options.userAgentAppendix} ${options.rest.userAgentAppendix}`
: undefined,
},
});
/**
* The REST manager of the client