InviteDelete.js (953B)
1 'use strict'; 2 3 const Action = require('./Action'); 4 const Invite = require('../../structures/Invite'); 5 const { Events } = require('../../util/Constants'); 6 7 class InviteDeleteAction 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 /** 18 * Emitted when an invite is deleted. 19 * <info> This event only triggers if the client has `MANAGE_GUILD` permissions for the guild, 20 * or `MANAGE_CHANNEL` permissions for the channel.</info> 21 * @event Client#inviteDelete 22 * @param {Invite} invite The invite that was deleted 23 */ 24 client.emit(Events.INVITE_DELETE, invite); 25 return { invite }; 26 } 27 } 28 29 module.exports = InviteDeleteAction;