mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +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
|
* @param {ClientUserEditOptions} options The options to provide
|
||||||
* @returns {Promise<ClientUser>}
|
* @returns {Promise<ClientUser>}
|
||||||
*/
|
*/
|
||||||
async edit(options) {
|
async edit({ username, avatar }) {
|
||||||
if (options.avatar !== undefined) options.avatar = await DataResolver.resolveImage(options.avatar);
|
const data = await this.client.rest.patch(Routes.user(), {
|
||||||
const newData = await this.client.rest.patch(Routes.user(), { body: options });
|
body: { username, avatar: avatar && (await DataResolver.resolveImage(avatar)) },
|
||||||
this.client.token = newData.token;
|
});
|
||||||
this.client.rest.setToken(newData.token);
|
|
||||||
const { updated } = this.client.actions.UserUpdate.handle(newData);
|
this.client.token = data.token;
|
||||||
|
this.client.rest.setToken(data.token);
|
||||||
|
const { updated } = this.client.actions.UserUpdate.handle(data);
|
||||||
return updated ?? this;
|
return updated ?? this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user