Skip to content

Commit 217e5d8

Browse files
authored
fix(BaseClient): Prevent user agent mutation (#9425)
fix(BaseClient): prevent user agent mutation
1 parent 40d07fb commit 217e5d8

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

packages/discord.js/src/client/BaseClient.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ class BaseClient extends EventEmitter {
1818
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'options', 'object', true);
1919
}
2020

21-
if (options.rest?.userAgentAppendix) {
22-
// Merging the default options when a custom user agent appendix is supplied
23-
// Replaces the discord.js string. Enforce it.
24-
options.rest.userAgentAppendix = `${Options.userAgentAppendix} ${options.rest.userAgentAppendix}`;
25-
}
26-
2721
/**
2822
* The options the client was instantiated with
2923
* @type {ClientOptions}
3024
*/
31-
this.options = mergeDefault(Options.createDefault(), options);
25+
this.options = mergeDefault(Options.createDefault(), {
26+
...options,
27+
rest: {
28+
...options.rest,
29+
userAgentAppendix: options.rest?.userAgentAppendix
30+
? `${Options.userAgentAppendix} ${options.rest.userAgentAppendix}`
31+
: undefined,
32+
},
33+
});
3234

3335
/**
3436
* The REST manager of the client

0 commit comments

Comments
 (0)