You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
715 B
JavaScript
34 lines
715 B
JavaScript
const Action = require('./Action');
|
|
const Constants = require('../../util/Constants');
|
|
const Util = require('../../util/Util');
|
|
|
|
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 = Util.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;
|