diff --git a/packages/discord.js/src/client/BaseClient.js b/packages/discord.js/src/client/BaseClient.js index 65e19c25309b..91c6afac3677 100644 --- a/packages/discord.js/src/client/BaseClient.js +++ b/packages/discord.js/src/client/BaseClient.js @@ -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