Skip to content

Commit

Permalink
fix(ClientUser): No mutation on edit (#9259)
Browse files Browse the repository at this point in the history
fix(ClientUser): no mutation on edit

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] committed Mar 25, 2023
1 parent 44ef2d9 commit abd6ae9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/discord.js/src/structures/ClientUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ class ClientUser extends User {
* @param {ClientUserEditOptions} options The options to provide
* @returns {Promise<ClientUser>}
*/
async edit(options) {
if (options.avatar !== undefined) options.avatar = await DataResolver.resolveImage(options.avatar);
const newData = await this.client.rest.patch(Routes.user(), { body: options });
this.client.token = newData.token;
this.client.rest.setToken(newData.token);
const { updated } = this.client.actions.UserUpdate.handle(newData);
async edit({ username, avatar }) {
const data = await this.client.rest.patch(Routes.user(), {
body: { username, avatar: avatar && (await DataResolver.resolveImage(avatar)) },
});

this.client.token = data.token;
this.client.rest.setToken(data.token);
const { updated } = this.client.actions.UserUpdate.handle(data);
return updated ?? this;
}

Expand Down

2 comments on commit abd6ae9

@vercel
Copy link

@vercel vercel bot commented on abd6ae9 Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on abd6ae9 Mar 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.