-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
InviteCreate.js
28 lines (23 loc) · 909 Bytes
/
InviteCreate.js
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
'use strict';
const Action = require('./Action');
const Events = require('../../util/Events');
class InviteCreateAction 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 = guild.invites._add(inviteData);
/**
* Emitted when an invite is created.
* <info>This event requires either the {@link PermissionFlagsBits.ManageGuild} permission or the
* {@link PermissionFlagsBits.ManageChannels} permission for the channel.</info>
* @event Client#inviteCreate
* @param {Invite} invite The invite that was created
*/
client.emit(Events.InviteCreate, invite);
return { invite };
}
}
module.exports = InviteCreateAction;