Fix setting guild role positions (#751)

This commit is contained in:
Amish Shah
2016-10-26 14:19:36 +01:00
parent add52ce62d
commit 0c4a4023ce
6 changed files with 72 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
const Action = require('./Action');
class GuildRolesPositionUpdate extends Action {
handle(data) {
const client = this.client;
const guild = client.guilds.get(data.guild_id);
if (guild) {
for (const partialRole of data.roles) {
const role = guild.roles.get(partialRole.id);
if (role) {
role.position = partialRole.position;
}
}
}
return {
guild,
};
}
}
/**
* Emitted whenever a guild role is created.
* @event Client#guildRoleCreate
* @param {Guild} guild The guild that the role was created in.
* @param {Role} role The role that was created.
*/
module.exports = GuildRolesPositionUpdate;