mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user