mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
Clean up Actions code (#591)
This commit is contained in:
committed by
Amish Shah
parent
432c5ccc82
commit
59a5862f2d
@@ -6,23 +6,22 @@ class GuildRoleUpdateAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
|
||||
const guild = client.guilds.get(data.guild_id);
|
||||
|
||||
const roleData = data.role;
|
||||
|
||||
if (guild) {
|
||||
let oldRole;
|
||||
const existingRole = guild.roles.get(roleData.id);
|
||||
// exists and not the same
|
||||
if (existingRole && !existingRole.equals(roleData)) {
|
||||
oldRole = cloneObject(existingRole);
|
||||
existingRole.setup(data.role);
|
||||
client.emit(Constants.Events.GUILD_ROLE_UPDATE, guild, oldRole, existingRole);
|
||||
const roleData = data.role;
|
||||
let oldRole = null;
|
||||
|
||||
const role = guild.roles.get(roleData.id);
|
||||
if (role && !role.equals(roleData)) {
|
||||
oldRole = cloneObject(role);
|
||||
role.setup(data.role);
|
||||
client.emit(Constants.Events.GUILD_ROLE_UPDATE, guild, oldRole, role);
|
||||
}
|
||||
|
||||
return {
|
||||
old: oldRole,
|
||||
updated: existingRole,
|
||||
updated: role,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user