buddy

node MVC discord bot
Log | Files | Refs | README

InviteCreate.js (952B)


      1 'use strict';
      2 
      3 const Action = require('./Action');
      4 const Invite = require('../../structures/Invite');
      5 const { Events } = require('../../util/Constants');
      6 
      7 class InviteCreateAction extends Action {
      8   handle(data) {
      9     const client = this.client;
     10     const channel = client.channels.cache.get(data.channel_id);
     11     const guild = client.guilds.cache.get(data.guild_id);
     12     if (!channel && !guild) return false;
     13 
     14     const inviteData = Object.assign(data, { channel, guild });
     15     const invite = new Invite(client, inviteData);
     16     /**
     17      * Emitted when an invite is created.
     18      * <info> This event only triggers if the client has `MANAGE_GUILD` permissions for the guild,
     19      * or `MANAGE_CHANNEL` permissions for the channel.</info>
     20      * @event Client#inviteCreate
     21      * @param {Invite} invite The invite that was created
     22      */
     23     client.emit(Events.INVITE_CREATE, invite);
     24     return { invite };
     25   }
     26 }
     27 
     28 module.exports = InviteCreateAction;