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;