buddy

node MVC discord bot
Log | Files | Refs | README

GuildRoleDelete.js (738B)


      1 'use strict';
      2 
      3 const Action = require('./Action');
      4 const { Events } = require('../../util/Constants');
      5 
      6 class GuildRoleDeleteAction extends Action {
      7   handle(data) {
      8     const client = this.client;
      9     const guild = client.guilds.cache.get(data.guild_id);
     10     let role;
     11 
     12     if (guild) {
     13       role = guild.roles.cache.get(data.role_id);
     14       if (role) {
     15         guild.roles.cache.delete(data.role_id);
     16         role.deleted = true;
     17         /**
     18          * Emitted whenever a guild role is deleted.
     19          * @event Client#roleDelete
     20          * @param {Role} role The role that was deleted
     21          */
     22         client.emit(Events.GUILD_ROLE_DELETE, role);
     23       }
     24     }
     25 
     26     return { role };
     27   }
     28 }
     29 
     30 module.exports = GuildRoleDeleteAction;