Skip to content

Commit abd6ae9

Browse files
fix(ClientUser): No mutation on edit (#9259)
fix(ClientUser): no mutation on edit Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 44ef2d9 commit abd6ae9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/discord.js/src/structures/ClientUser.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,14 @@ class ClientUser extends User {
5454
* @param {ClientUserEditOptions} options The options to provide
5555
* @returns {Promise<ClientUser>}
5656
*/
57-
async edit(options) {
58-
if (options.avatar !== undefined) options.avatar = await DataResolver.resolveImage(options.avatar);
59-
const newData = await this.client.rest.patch(Routes.user(), { body: options });
60-
this.client.token = newData.token;
61-
this.client.rest.setToken(newData.token);
62-
const { updated } = this.client.actions.UserUpdate.handle(newData);
57+
async edit({ username, avatar }) {
58+
const data = await this.client.rest.patch(Routes.user(), {
59+
body: { username, avatar: avatar && (await DataResolver.resolveImage(avatar)) },
60+
});
61+
62+
this.client.token = data.token;
63+
this.client.rest.setToken(data.token);
64+
const { updated } = this.client.actions.UserUpdate.handle(data);
6365
return updated ?? this;
6466
}
6567

0 commit comments

Comments
 (0)