mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
* Cleanup Part 2: Electric Boogaloo (Reloaded) * Moar cleanup * Tweak NOT_A_PERMISSION error
41 lines
980 B
JavaScript
41 lines
980 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.setup(data);
|
|
client.emit(Constants.Events.USER_UPDATE, oldUser, client.user);
|
|
return {
|
|
old: oldUser,
|
|
updated: client.user,
|
|
};
|
|
}
|
|
|
|
return {
|
|
old: null,
|
|
updated: null,
|
|
};
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Emitted whenever a detail of the logged in User changes - e.g. username.
|
|
* @event Client#userUpdate
|
|
* @param {ClientUser} oldClientUser The client user before the update.
|
|
* @param {ClientUser} newClientUser The client user after the update.
|
|
*/
|
|
|
|
module.exports = UserUpdateAction;
|