Added guild.createRole()

This commit is contained in:
Amish Shah
2016-07-02 21:28:49 +01:00
parent bbf0b0683a
commit 849b8df2da
8 changed files with 382 additions and 332 deletions

View File

@@ -0,0 +1,38 @@
'use strict';
const Action = require('./Action');
const Constants = require('../../util/Constants');
const Role = require('../../structures/Role');
class GuildRoleCreate extends Action {
constructor(client) {
super(client);
}
handle(data) {
let client = this.client;
let guild = client.store.get('guilds', data.guild_id);
if (guild) {
let already = guild.store.get('roles', data.role.id);
let role = new Role(guild, data.role);
guild.store.add('roles', role);
if (!already) {
client.emit(Constants.Events.GUILD_ROLE_CREATE, guild, role);
}
return {
role,
};
}
return {
role: null,
};
}
};
module.exports = GuildRoleCreate;