discord.js-selfbot-v13/src/client/actions/InviteDelete.js

31 lines
981 B
JavaScript
Raw Normal View History

2022-03-19 10:37:45 +00:00
'use strict';
const Action = require('./Action');
const Invite = require('../../structures/Invite');
const Events = require('../../util/Events');
class InviteDeleteAction extends Action {
handle(data) {
const client = this.client;
const channel = client.channels.cache.get(data.channel_id);
const guild = client.guilds.cache.get(data.guild_id);
if (!channel) return false;
const inviteData = Object.assign(data, { channel, guild });
const invite = new Invite(client, inviteData);
guild.invites.cache.delete(invite.code);
/**
* Emitted when an invite is deleted.
* <info> This event only triggers if the client has `MANAGE_GUILD` permissions for the guild,
* or `MANAGE_CHANNELS` permissions for the channel.</info>
* @event Client#inviteDelete
* @param {Invite} invite The invite that was deleted
*/
client.emit(Events.InviteDelete, invite);
return { invite };
}
}
module.exports = InviteDeleteAction;