mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
34 lines
724 B
JavaScript
34 lines
724 B
JavaScript
const Action = require('./Action');
|
|
const Constants = require('../../util/Constants');
|
|
const cloneObject = require('../../util/CloneObject');
|
|
|
|
class UserUpdateAction extends Action {
|
|
handle(data) {
|
|
const client = this.client;
|
|
|
|
if (client.user) {
|
|
if (client.user.equals(data)) {
|
|
return {
|
|
old: client.user,
|
|
updated: client.user,
|
|
};
|
|
}
|
|
|
|
const oldUser = cloneObject(client.user);
|
|
client.user.patch(data);
|
|
client.emit(Constants.Events.USER_UPDATE, oldUser, client.user);
|
|
return {
|
|
old: oldUser,
|
|
updated: client.user,
|
|
};
|
|
}
|
|
|
|
return {
|
|
old: null,
|
|
updated: null,
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = UserUpdateAction;
|