summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions/GuildRoleDelete.js
blob: e043a1aeb404922715d9a96962e094443bf31f41 (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
26
27
28
29
'use strict';

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

class GuildRoleDeleteAction extends Action {
  handle(data) {
    const client = this.client;
    const guild = client.guilds.cache.get(data.guild_id);
    let role;

    if (guild) {
      role = guild.roles.cache.get(data.role_id);
      if (role) {
        guild.roles.cache.delete(data.role_id);
        /**
         * Emitted whenever a guild role is deleted.
         * @event Client#roleDelete
         * @param {Role} role The role that was deleted
         */
        client.emit(Events.GuildRoleDelete, role);
      }
    }

    return { role };
  }
}

module.exports = GuildRoleDeleteAction;