summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions/GuildRoleCreate.js
blob: 461443bdb217927015c81ed2ee78c748e6a70ab1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';

const Action = require('./Action');
const Events = require('../../util/Events');

class GuildRoleCreate extends Action {
  handle(data) {
    const client = this.client;
    const guild = client.guilds.cache.get(data.guild_id);
    let role;
    if (guild) {
      const already = guild.roles.cache.has(data.role.id);
      role = guild.roles._add(data.role);
      /**
       * Emitted whenever a role is created.
       * @event Client#roleCreate
       * @param {Role} role The role that was created
       */
      if (!already) client.emit(Events.GuildRoleCreate, role);
    }
    return { role };
  }
}

module.exports = GuildRoleCreate;