mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 20:13:30 +01:00
fix(BaseClient): Prevent user agent mutation (#9425)
fix(BaseClient): prevent user agent mutation
This commit is contained in:
@@ -18,17 +18,19 @@ class BaseClient extends EventEmitter {
|
|||||||
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
|
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
|
* The options the client was instantiated with
|
||||||
* @type {ClientOptions}
|
* @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
|
* The REST manager of the client
|
||||||
|
|||||||
Reference in New Issue
Block a user