GuildRoleCreate.js (667B)
1 'use strict'; 2 3 const Action = require('./Action'); 4 const { Events } = require('../../util/Constants'); 5 6 class GuildRoleCreate extends Action { 7 handle(data) { 8 const client = this.client; 9 const guild = client.guilds.cache.get(data.guild_id); 10 let role; 11 if (guild) { 12 const already = guild.roles.cache.has(data.role.id); 13 role = guild.roles.add(data.role); 14 /** 15 * Emitted whenever a role is created. 16 * @event Client#roleCreate 17 * @param {Role} role The role that was created 18 */ 19 if (!already) client.emit(Events.GUILD_ROLE_CREATE, role); 20 } 21 return { role }; 22 } 23 } 24 25 module.exports = GuildRoleCreate;