summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions
diff options
context:
space:
mode:
author8cy <[email protected]>2020-04-30 15:46:16 -0700
committer8cy <[email protected]>2020-04-30 15:46:16 -0700
commit3a4deac89054021b56ad5bd8005b2044cc085c98 (patch)
tree3dd6af8503e497e46180b6b5231674f36bdce9f2 /node_modules/discord.js/src/client/actions
downloaduppity-3a4deac89054021b56ad5bd8005b2044cc085c98.tar.xz
uppity-3a4deac89054021b56ad5bd8005b2044cc085c98.zip
Up, up, uppity.
Diffstat (limited to 'node_modules/discord.js/src/client/actions')
-rw-r--r--node_modules/discord.js/src/client/actions/Action.js103
-rw-r--r--node_modules/discord.js/src/client/actions/ActionsManager.js45
-rw-r--r--node_modules/discord.js/src/client/actions/ChannelCreate.js23
-rw-r--r--node_modules/discord.js/src/client/actions/ChannelDelete.js37
-rw-r--r--node_modules/discord.js/src/client/actions/ChannelUpdate.js33
-rw-r--r--node_modules/discord.js/src/client/actions/GuildBanRemove.js21
-rw-r--r--node_modules/discord.js/src/client/actions/GuildChannelsPositionUpdate.js21
-rw-r--r--node_modules/discord.js/src/client/actions/GuildDelete.js67
-rw-r--r--node_modules/discord.js/src/client/actions/GuildEmojiCreate.js19
-rw-r--r--node_modules/discord.js/src/client/actions/GuildEmojiDelete.js20
-rw-r--r--node_modules/discord.js/src/client/actions/GuildEmojiUpdate.js20
-rw-r--r--node_modules/discord.js/src/client/actions/GuildEmojisUpdate.js34
-rw-r--r--node_modules/discord.js/src/client/actions/GuildIntegrationsUpdate.js19
-rw-r--r--node_modules/discord.js/src/client/actions/GuildMemberRemove.js30
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRoleCreate.js25
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRoleDelete.js30
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRoleUpdate.js39
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRolesPositionUpdate.js21
-rw-r--r--node_modules/discord.js/src/client/actions/GuildUpdate.js33
-rw-r--r--node_modules/discord.js/src/client/actions/InviteCreate.js28
-rw-r--r--node_modules/discord.js/src/client/actions/InviteDelete.js29
-rw-r--r--node_modules/discord.js/src/client/actions/MessageCreate.js39
-rw-r--r--node_modules/discord.js/src/client/actions/MessageDelete.js29
-rw-r--r--node_modules/discord.js/src/client/actions/MessageDeleteBulk.js43
-rw-r--r--node_modules/discord.js/src/client/actions/MessageReactionAdd.js50
-rw-r--r--node_modules/discord.js/src/client/actions/MessageReactionRemove.js44
-rw-r--r--node_modules/discord.js/src/client/actions/MessageReactionRemoveAll.js29
-rw-r--r--node_modules/discord.js/src/client/actions/MessageReactionRemoveEmoji.js28
-rw-r--r--node_modules/discord.js/src/client/actions/MessageUpdate.js24
-rw-r--r--node_modules/discord.js/src/client/actions/PresenceUpdate.js44
-rw-r--r--node_modules/discord.js/src/client/actions/UserUpdate.js34
-rw-r--r--node_modules/discord.js/src/client/actions/VoiceStateUpdate.js44
-rw-r--r--node_modules/discord.js/src/client/actions/WebhooksUpdate.js19
33 files changed, 1124 insertions, 0 deletions
diff --git a/node_modules/discord.js/src/client/actions/Action.js b/node_modules/discord.js/src/client/actions/Action.js
new file mode 100644
index 0000000..d9519b5
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/Action.js
@@ -0,0 +1,103 @@
+'use strict';
+
+const { PartialTypes } = require('../../util/Constants');
+
+/*
+
+ABOUT ACTIONS
+
+Actions are similar to WebSocket Packet Handlers, but since introducing
+the REST API methods, in order to prevent rewriting code to handle data,
+"actions" have been introduced. They're basically what Packet Handlers
+used to be but they're strictly for manipulating data and making sure
+that WebSocket events don't clash with REST methods.
+
+*/
+
+class GenericAction {
+ constructor(client) {
+ this.client = client;
+ }
+
+ handle(data) {
+ return data;
+ }
+
+ getPayload(data, manager, id, partialType, cache) {
+ const existing = manager.cache.get(id);
+ if (!existing && this.client.options.partials.includes(partialType)) {
+ return manager.add(data, cache);
+ }
+ return existing;
+ }
+
+ getChannel(data) {
+ const id = data.channel_id || data.id;
+ return (
+ data.channel ||
+ this.getPayload(
+ {
+ id,
+ guild_id: data.guild_id,
+ recipients: [data.author || { id: data.user_id }],
+ },
+ this.client.channels,
+ id,
+ PartialTypes.CHANNEL,
+ )
+ );
+ }
+
+ getMessage(data, channel, cache) {
+ const id = data.message_id || data.id;
+ return (
+ data.message ||
+ this.getPayload(
+ {
+ id,
+ channel_id: channel.id,
+ guild_id: data.guild_id || (channel.guild ? channel.guild.id : null),
+ },
+ channel.messages,
+ id,
+ PartialTypes.MESSAGE,
+ cache,
+ )
+ );
+ }
+
+ getReaction(data, message, user) {
+ const id = data.emoji.id || decodeURIComponent(data.emoji.name);
+ return this.getPayload(
+ {
+ emoji: data.emoji,
+ count: message.partial ? null : 0,
+ me: user ? user.id === this.client.user.id : false,
+ },
+ message.reactions,
+ id,
+ PartialTypes.REACTION,
+ );
+ }
+
+ getMember(data, guild) {
+ const id = data.user.id;
+ return this.getPayload(
+ {
+ user: {
+ id,
+ },
+ },
+ guild.members,
+ id,
+ PartialTypes.GUILD_MEMBER,
+ );
+ }
+
+ getUser(data) {
+ const id = data.user_id;
+ return data.user || this.getPayload({ id }, this.client.users, id, PartialTypes.USER);
+ }
+}
+
+module.exports = GenericAction;
diff --git a/node_modules/discord.js/src/client/actions/ActionsManager.js b/node_modules/discord.js/src/client/actions/ActionsManager.js
new file mode 100644
index 0000000..7e1df12
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ActionsManager.js
@@ -0,0 +1,45 @@
+'use strict';
+
+class ActionsManager {
+ constructor(client) {
+ this.client = client;
+
+ this.register(require('./MessageCreate'));
+ this.register(require('./MessageDelete'));
+ this.register(require('./MessageDeleteBulk'));
+ this.register(require('./MessageUpdate'));
+ this.register(require('./MessageReactionAdd'));
+ this.register(require('./MessageReactionRemove'));
+ this.register(require('./MessageReactionRemoveAll'));
+ this.register(require('./MessageReactionRemoveEmoji'));
+ this.register(require('./ChannelCreate'));
+ this.register(require('./ChannelDelete'));
+ this.register(require('./ChannelUpdate'));
+ this.register(require('./GuildDelete'));
+ this.register(require('./GuildUpdate'));
+ this.register(require('./InviteCreate'));
+ this.register(require('./InviteDelete'));
+ this.register(require('./GuildMemberRemove'));
+ this.register(require('./GuildBanRemove'));
+ this.register(require('./GuildRoleCreate'));
+ this.register(require('./GuildRoleDelete'));
+ this.register(require('./GuildRoleUpdate'));
+ this.register(require('./PresenceUpdate'));
+ this.register(require('./UserUpdate'));
+ this.register(require('./VoiceStateUpdate'));
+ this.register(require('./GuildEmojiCreate'));
+ this.register(require('./GuildEmojiDelete'));
+ this.register(require('./GuildEmojiUpdate'));
+ this.register(require('./GuildEmojisUpdate'));
+ this.register(require('./GuildRolesPositionUpdate'));
+ this.register(require('./GuildChannelsPositionUpdate'));
+ this.register(require('./GuildIntegrationsUpdate'));
+ this.register(require('./WebhooksUpdate'));
+ }
+
+ register(Action) {
+ this[Action.name.replace(/Action$/, '')] = new Action(this.client);
+ }
+}
+
+module.exports = ActionsManager;
diff --git a/node_modules/discord.js/src/client/actions/ChannelCreate.js b/node_modules/discord.js/src/client/actions/ChannelCreate.js
new file mode 100644
index 0000000..fa60a0b
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ChannelCreate.js
@@ -0,0 +1,23 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class ChannelCreateAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const existing = client.channels.cache.has(data.id);
+ const channel = client.channels.add(data);
+ if (!existing && channel) {
+ /**
+ * Emitted whenever a channel is created.
+ * @event Client#channelCreate
+ * @param {DMChannel|GuildChannel} channel The channel that was created
+ */
+ client.emit(Events.CHANNEL_CREATE, channel);
+ }
+ return { channel };
+ }
+}
+
+module.exports = ChannelCreateAction;
diff --git a/node_modules/discord.js/src/client/actions/ChannelDelete.js b/node_modules/discord.js/src/client/actions/ChannelDelete.js
new file mode 100644
index 0000000..2956d72
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ChannelDelete.js
@@ -0,0 +1,37 @@
+'use strict';
+
+const Action = require('./Action');
+const DMChannel = require('../../structures/DMChannel');
+const { Events } = require('../../util/Constants');
+
+class ChannelDeleteAction extends Action {
+ constructor(client) {
+ super(client);
+ this.deleted = new Map();
+ }
+
+ handle(data) {
+ const client = this.client;
+ let channel = client.channels.cache.get(data.id);
+
+ if (channel) {
+ client.channels.remove(channel.id);
+ channel.deleted = true;
+ if (channel.messages && !(channel instanceof DMChannel)) {
+ for (const message of channel.messages.cache.values()) {
+ message.deleted = true;
+ }
+ }
+ /**
+ * Emitted whenever a channel is deleted.
+ * @event Client#channelDelete
+ * @param {DMChannel|GuildChannel} channel The channel that was deleted
+ */
+ client.emit(Events.CHANNEL_DELETE, channel);
+ }
+
+ return { channel };
+ }
+}
+
+module.exports = ChannelDeleteAction;
diff --git a/node_modules/discord.js/src/client/actions/ChannelUpdate.js b/node_modules/discord.js/src/client/actions/ChannelUpdate.js
new file mode 100644
index 0000000..06bb71b
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ChannelUpdate.js
@@ -0,0 +1,33 @@
+'use strict';
+
+const Action = require('./Action');
+const Channel = require('../../structures/Channel');
+const { ChannelTypes } = require('../../util/Constants');
+
+class ChannelUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ let channel = client.channels.cache.get(data.id);
+ if (channel) {
+ const old = channel._update(data);
+
+ if (ChannelTypes[channel.type.toUpperCase()] !== data.type) {
+ const newChannel = Channel.create(this.client, data, channel.guild);
+ for (const [id, message] of channel.messages.cache) newChannel.messages.cache.set(id, message);
+ newChannel._typing = new Map(channel._typing);
+ channel = newChannel;
+ this.client.channels.cache.set(channel.id, channel);
+ }
+
+ return {
+ old,
+ updated: channel,
+ };
+ }
+
+ return {};
+ }
+}
+
+module.exports = ChannelUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildBanRemove.js b/node_modules/discord.js/src/client/actions/GuildBanRemove.js
new file mode 100644
index 0000000..fc28e11
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildBanRemove.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildBanRemove extends Action {
+ handle(data) {
+ const client = this.client;
+ const guild = client.guilds.cache.get(data.guild_id);
+ const user = client.users.add(data.user);
+ /**
+ * Emitted whenever a member is unbanned from a guild.
+ * @event Client#guildBanRemove
+ * @param {Guild} guild The guild that the unban occurred in
+ * @param {User} user The user that was unbanned
+ */
+ if (guild && user) client.emit(Events.GUILD_BAN_REMOVE, guild, user);
+ }
+}
+
+module.exports = GuildBanRemove;
diff --git a/node_modules/discord.js/src/client/actions/GuildChannelsPositionUpdate.js b/node_modules/discord.js/src/client/actions/GuildChannelsPositionUpdate.js
new file mode 100644
index 0000000..a393167
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildChannelsPositionUpdate.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const Action = require('./Action');
+
+class GuildChannelsPositionUpdate extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.cache.get(data.guild_id);
+ if (guild) {
+ for (const partialChannel of data.channels) {
+ const channel = guild.channels.cache.get(partialChannel.id);
+ if (channel) channel.rawPosition = partialChannel.position;
+ }
+ }
+
+ return { guild };
+ }
+}
+
+module.exports = GuildChannelsPositionUpdate;
diff --git a/node_modules/discord.js/src/client/actions/GuildDelete.js b/node_modules/discord.js/src/client/actions/GuildDelete.js
new file mode 100644
index 0000000..8bb630f
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildDelete.js
@@ -0,0 +1,67 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildDeleteAction extends Action {
+ constructor(client) {
+ super(client);
+ this.deleted = new Map();
+ }
+
+ handle(data) {
+ const client = this.client;
+
+ let guild = client.guilds.cache.get(data.id);
+ if (guild) {
+ for (const channel of guild.channels.cache.values()) {
+ if (channel.type === 'text') channel.stopTyping(true);
+ }
+
+ if (data.unavailable) {
+ // Guild is unavailable
+ guild.available = false;
+
+ /**
+ * Emitted whenever a guild becomes unavailable, likely due to a server outage.
+ * @event Client#guildUnavailable
+ * @param {Guild} guild The guild that has become unavailable
+ */
+ client.emit(Events.GUILD_UNAVAILABLE, guild);
+
+ // Stops the GuildDelete packet thinking a guild was actually deleted,
+ // handles emitting of event itself
+ return {
+ guild: null,
+ };
+ }
+
+ for (const channel of guild.channels.cache.values()) this.client.channels.remove(channel.id);
+ if (guild.voice && guild.voice.connection) guild.voice.connection.disconnect();
+
+ // Delete guild
+ client.guilds.cache.delete(guild.id);
+ guild.deleted = true;
+
+ /**
+ * Emitted whenever a guild kicks the client or the guild is deleted/left.
+ * @event Client#guildDelete
+ * @param {Guild} guild The guild that was deleted
+ */
+ client.emit(Events.GUILD_DELETE, guild);
+
+ this.deleted.set(guild.id, guild);
+ this.scheduleForDeletion(guild.id);
+ } else {
+ guild = this.deleted.get(data.id) || null;
+ }
+
+ return { guild };
+ }
+
+ scheduleForDeletion(id) {
+ this.client.setTimeout(() => this.deleted.delete(id), this.client.options.restWsBridgeTimeout);
+ }
+}
+
+module.exports = GuildDeleteAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildEmojiCreate.js b/node_modules/discord.js/src/client/actions/GuildEmojiCreate.js
new file mode 100644
index 0000000..379c62e
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildEmojiCreate.js
@@ -0,0 +1,19 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildEmojiCreateAction extends Action {
+ handle(guild, createdEmoji) {
+ const emoji = guild.emojis.add(createdEmoji);
+ /**
+ * Emitted whenever a custom emoji is created in a guild.
+ * @event Client#emojiCreate
+ * @param {GuildEmoji} emoji The emoji that was created
+ */
+ this.client.emit(Events.GUILD_EMOJI_CREATE, emoji);
+ return { emoji };
+ }
+}
+
+module.exports = GuildEmojiCreateAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildEmojiDelete.js b/node_modules/discord.js/src/client/actions/GuildEmojiDelete.js
new file mode 100644
index 0000000..42af70c
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildEmojiDelete.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildEmojiDeleteAction extends Action {
+ handle(emoji) {
+ emoji.guild.emojis.cache.delete(emoji.id);
+ emoji.deleted = true;
+ /**
+ * Emitted whenever a custom emoji is deleted in a guild.
+ * @event Client#emojiDelete
+ * @param {GuildEmoji} emoji The emoji that was deleted
+ */
+ this.client.emit(Events.GUILD_EMOJI_DELETE, emoji);
+ return { emoji };
+ }
+}
+
+module.exports = GuildEmojiDeleteAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildEmojiUpdate.js b/node_modules/discord.js/src/client/actions/GuildEmojiUpdate.js
new file mode 100644
index 0000000..9fa59c9
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildEmojiUpdate.js
@@ -0,0 +1,20 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildEmojiUpdateAction extends Action {
+ handle(current, data) {
+ const old = current._update(data);
+ /**
+ * Emitted whenever a custom emoji is updated in a guild.
+ * @event Client#emojiUpdate
+ * @param {GuildEmoji} oldEmoji The old emoji
+ * @param {GuildEmoji} newEmoji The new emoji
+ */
+ this.client.emit(Events.GUILD_EMOJI_UPDATE, old, current);
+ return { emoji: current };
+ }
+}
+
+module.exports = GuildEmojiUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildEmojisUpdate.js b/node_modules/discord.js/src/client/actions/GuildEmojisUpdate.js
new file mode 100644
index 0000000..7711933
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildEmojisUpdate.js
@@ -0,0 +1,34 @@
+'use strict';
+
+const Action = require('./Action');
+
+class GuildEmojisUpdateAction extends Action {
+ handle(data) {
+ const guild = this.client.guilds.cache.get(data.guild_id);
+ if (!guild || !guild.emojis) return;
+
+ const deletions = new Map(guild.emojis.cache);
+
+ for (const emoji of data.emojis) {
+ // Determine type of emoji event
+ const cachedEmoji = guild.emojis.cache.get(emoji.id);
+ if (cachedEmoji) {
+ deletions.delete(emoji.id);
+ if (!cachedEmoji.equals(emoji)) {
+ // Emoji updated
+ this.client.actions.GuildEmojiUpdate.handle(cachedEmoji, emoji);
+ }
+ } else {
+ // Emoji added
+ this.client.actions.GuildEmojiCreate.handle(guild, emoji);
+ }
+ }
+
+ for (const emoji of deletions.values()) {
+ // Emoji deleted
+ this.client.actions.GuildEmojiDelete.handle(emoji);
+ }
+ }
+}
+
+module.exports = GuildEmojisUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildIntegrationsUpdate.js b/node_modules/discord.js/src/client/actions/GuildIntegrationsUpdate.js
new file mode 100644
index 0000000..bbce076
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildIntegrationsUpdate.js
@@ -0,0 +1,19 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildIntegrationsUpdate extends Action {
+ handle(data) {
+ const client = this.client;
+ const guild = client.guilds.cache.get(data.guild_id);
+ /**
+ * Emitted whenever a guild integration is updated
+ * @event Client#guildIntegrationsUpdate
+ * @param {Guild} guild The guild whose integrations were updated
+ */
+ if (guild) client.emit(Events.GUILD_INTEGRATIONS_UPDATE, guild);
+ }
+}
+
+module.exports = GuildIntegrationsUpdate;
diff --git a/node_modules/discord.js/src/client/actions/GuildMemberRemove.js b/node_modules/discord.js/src/client/actions/GuildMemberRemove.js
new file mode 100644
index 0000000..f0fe3b3
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildMemberRemove.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events, Status } = require('../../util/Constants');
+
+class GuildMemberRemoveAction extends Action {
+ handle(data, shard) {
+ const client = this.client;
+ const guild = client.guilds.cache.get(data.guild_id);
+ let member = null;
+ if (guild) {
+ member = this.getMember(data, guild);
+ guild.memberCount--;
+ if (member) {
+ member.deleted = true;
+ guild.members.cache.delete(member.id);
+ /**
+ * Emitted whenever a member leaves a guild, or is kicked.
+ * @event Client#guildMemberRemove
+ * @param {GuildMember} member The member that has left/been kicked from the guild
+ */
+ if (shard.status === Status.READY) client.emit(Events.GUILD_MEMBER_REMOVE, member);
+ }
+ guild.voiceStates.cache.delete(data.user.id);
+ }
+ return { guild, member };
+ }
+}
+
+module.exports = GuildMemberRemoveAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildRoleCreate.js b/node_modules/discord.js/src/client/actions/GuildRoleCreate.js
new file mode 100644
index 0000000..d7d5214
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRoleCreate.js
@@ -0,0 +1,25 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildRoleCreate extends Action {
+ handle(data) {
+ const client = this.client;
+ const guild = client.guilds.cache.get(data.guild_id);
+ let role;
+ if (guild) {
+ const already = guild.roles.cache.has(data.role.id);
+ role = guild.roles.add(data.role);
+ /**
+ * Emitted whenever a role is created.
+ * @event Client#roleCreate
+ * @param {Role} role The role that was created
+ */
+ if (!already) client.emit(Events.GUILD_ROLE_CREATE, role);
+ }
+ return { role };
+ }
+}
+
+module.exports = GuildRoleCreate;
diff --git a/node_modules/discord.js/src/client/actions/GuildRoleDelete.js b/node_modules/discord.js/src/client/actions/GuildRoleDelete.js
new file mode 100644
index 0000000..51754b3
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRoleDelete.js
@@ -0,0 +1,30 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildRoleDeleteAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const guild = client.guilds.cache.get(data.guild_id);
+ let role;
+
+ if (guild) {
+ role = guild.roles.cache.get(data.role_id);
+ if (role) {
+ guild.roles.cache.delete(data.role_id);
+ role.deleted = true;
+ /**
+ * Emitted whenever a guild role is deleted.
+ * @event Client#roleDelete
+ * @param {Role} role The role that was deleted
+ */
+ client.emit(Events.GUILD_ROLE_DELETE, role);
+ }
+ }
+
+ return { role };
+ }
+}
+
+module.exports = GuildRoleDeleteAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildRoleUpdate.js b/node_modules/discord.js/src/client/actions/GuildRoleUpdate.js
new file mode 100644
index 0000000..faea120
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRoleUpdate.js
@@ -0,0 +1,39 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildRoleUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const guild = client.guilds.cache.get(data.guild_id);
+
+ if (guild) {
+ let old = null;
+
+ const role = guild.roles.cache.get(data.role.id);
+ if (role) {
+ old = role._update(data.role);
+ /**
+ * Emitted whenever a guild role is updated.
+ * @event Client#roleUpdate
+ * @param {Role} oldRole The role before the update
+ * @param {Role} newRole The role after the update
+ */
+ client.emit(Events.GUILD_ROLE_UPDATE, old, role);
+ }
+
+ return {
+ old,
+ updated: role,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+module.exports = GuildRoleUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildRolesPositionUpdate.js b/node_modules/discord.js/src/client/actions/GuildRolesPositionUpdate.js
new file mode 100644
index 0000000..d7abca9
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRolesPositionUpdate.js
@@ -0,0 +1,21 @@
+'use strict';
+
+const Action = require('./Action');
+
+class GuildRolesPositionUpdate extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.cache.get(data.guild_id);
+ if (guild) {
+ for (const partialRole of data.roles) {
+ const role = guild.roles.cache.get(partialRole.id);
+ if (role) role.rawPosition = partialRole.position;
+ }
+ }
+
+ return { guild };
+ }
+}
+
+module.exports = GuildRolesPositionUpdate;
diff --git a/node_modules/discord.js/src/client/actions/GuildUpdate.js b/node_modules/discord.js/src/client/actions/GuildUpdate.js
new file mode 100644
index 0000000..78a8afb
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildUpdate.js
@@ -0,0 +1,33 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class GuildUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.cache.get(data.id);
+ if (guild) {
+ const old = guild._update(data);
+ /**
+ * Emitted whenever a guild is updated - e.g. name change.
+ * @event Client#guildUpdate
+ * @param {Guild} oldGuild The guild before the update
+ * @param {Guild} newGuild The guild after the update
+ */
+ client.emit(Events.GUILD_UPDATE, old, guild);
+ return {
+ old,
+ updated: guild,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+module.exports = GuildUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/InviteCreate.js b/node_modules/discord.js/src/client/actions/InviteCreate.js
new file mode 100644
index 0000000..6381331
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/InviteCreate.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const Action = require('./Action');
+const Invite = require('../../structures/Invite');
+const { Events } = require('../../util/Constants');
+
+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 && !guild) return false;
+
+ const inviteData = Object.assign(data, { channel, guild });
+ const invite = new Invite(client, inviteData);
+ /**
+ * Emitted when an invite is created.
+ * <info> This event only triggers if the client has `MANAGE_GUILD` permissions for the guild,
+ * or `MANAGE_CHANNEL` permissions for the channel.</info>
+ * @event Client#inviteCreate
+ * @param {Invite} invite The invite that was created
+ */
+ client.emit(Events.INVITE_CREATE, invite);
+ return { invite };
+ }
+}
+
+module.exports = InviteCreateAction;
diff --git a/node_modules/discord.js/src/client/actions/InviteDelete.js b/node_modules/discord.js/src/client/actions/InviteDelete.js
new file mode 100644
index 0000000..92692c3
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/InviteDelete.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const Action = require('./Action');
+const Invite = require('../../structures/Invite');
+const { Events } = require('../../util/Constants');
+
+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 && !guild) return false;
+
+ const inviteData = Object.assign(data, { channel, guild });
+ const invite = new Invite(client, inviteData);
+
+ /**
+ * Emitted when an invite is deleted.
+ * <info> This event only triggers if the client has `MANAGE_GUILD` permissions for the guild,
+ * or `MANAGE_CHANNEL` permissions for the channel.</info>
+ * @event Client#inviteDelete
+ * @param {Invite} invite The invite that was deleted
+ */
+ client.emit(Events.INVITE_DELETE, invite);
+ return { invite };
+ }
+}
+
+module.exports = InviteDeleteAction;
diff --git a/node_modules/discord.js/src/client/actions/MessageCreate.js b/node_modules/discord.js/src/client/actions/MessageCreate.js
new file mode 100644
index 0000000..7138707
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageCreate.js
@@ -0,0 +1,39 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class MessageCreateAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const channel = client.channels.cache.get(data.channel_id);
+ if (channel) {
+ const existing = channel.messages.cache.get(data.id);
+ if (existing) return { message: existing };
+ const message = channel.messages.add(data);
+ const user = message.author;
+ let member = message.member;
+ channel.lastMessageID = data.id;
+ if (user) {
+ user.lastMessageID = data.id;
+ user.lastMessageChannelID = channel.id;
+ }
+ if (member) {
+ member.lastMessageID = data.id;
+ member.lastMessageChannelID = channel.id;
+ }
+
+ /**
+ * Emitted whenever a message is created.
+ * @event Client#message
+ * @param {Message} message The created message
+ */
+ client.emit(Events.MESSAGE_CREATE, message);
+ return { message };
+ }
+
+ return {};
+ }
+}
+
+module.exports = MessageCreateAction;
diff --git a/node_modules/discord.js/src/client/actions/MessageDelete.js b/node_modules/discord.js/src/client/actions/MessageDelete.js
new file mode 100644
index 0000000..0210625
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageDelete.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class MessageDeleteAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const channel = this.getChannel(data);
+ let message;
+ if (channel) {
+ message = this.getMessage(data, channel);
+ if (message) {
+ channel.messages.cache.delete(message.id);
+ message.deleted = true;
+ /**
+ * Emitted whenever a message is deleted.
+ * @event Client#messageDelete
+ * @param {Message} message The deleted message
+ */
+ client.emit(Events.MESSAGE_DELETE, message);
+ }
+ }
+
+ return { message };
+ }
+}
+
+module.exports = MessageDeleteAction;
diff --git a/node_modules/discord.js/src/client/actions/MessageDeleteBulk.js b/node_modules/discord.js/src/client/actions/MessageDeleteBulk.js
new file mode 100644
index 0000000..8686b1d
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageDeleteBulk.js
@@ -0,0 +1,43 @@
+'use strict';
+
+const Action = require('./Action');
+const Collection = require('../../util/Collection');
+const { Events } = require('../../util/Constants');
+
+class MessageDeleteBulkAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const channel = client.channels.cache.get(data.channel_id);
+
+ if (channel) {
+ const ids = data.ids;
+ const messages = new Collection();
+ for (const id of ids) {
+ const message = this.getMessage(
+ {
+ id,
+ guild_id: data.guild_id,
+ },
+ channel,
+ false,
+ );
+ if (message) {
+ message.deleted = true;
+ messages.set(message.id, message);
+ channel.messages.cache.delete(id);
+ }
+ }
+
+ /**
+ * Emitted whenever messages are deleted in bulk.
+ * @event Client#messageDeleteBulk
+ * @param {Collection<Snowflake, Message>} messages The deleted messages, mapped by their ID
+ */
+ if (messages.size > 0) client.emit(Events.MESSAGE_BULK_DELETE, messages);
+ return { messages };
+ }
+ return {};
+ }
+}
+
+module.exports = MessageDeleteBulkAction;
diff --git a/node_modules/discord.js/src/client/actions/MessageReactionAdd.js b/node_modules/discord.js/src/client/actions/MessageReactionAdd.js
new file mode 100644
index 0000000..22287db
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageReactionAdd.js
@@ -0,0 +1,50 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+const { PartialTypes } = require('../../util/Constants');
+
+/*
+{ user_id: 'id',
+ message_id: 'id',
+ emoji: { name: '�', id: null },
+ channel_id: 'id' } }
+*/
+
+class MessageReactionAdd extends Action {
+ handle(data) {
+ if (!data.emoji) return false;
+
+ const user = this.getUser(data);
+ if (!user) return false;
+
+ // Verify channel
+ const channel = this.getChannel(data);
+ if (!channel || channel.type === 'voice') return false;
+
+ // Verify message
+ const message = this.getMessage(data, channel);
+ if (!message) return false;
+
+ // Verify reaction
+ if (message.partial && !this.client.options.partials.includes(PartialTypes.REACTION)) return false;
+ const reaction = message.reactions.add({
+ emoji: data.emoji,
+ count: message.partial ? null : 0,
+ me: user.id === this.client.user.id,
+ });
+ if (!reaction) return false;
+ reaction._add(user);
+ /**
+ * Emitted whenever a reaction is added to a cached message.
+ * @event Client#messageReactionAdd
+ * @param {MessageReaction} messageReaction The reaction object
+ * @param {User} user The user that applied the guild or reaction emoji
+ */
+ this.client.emit(Events.MESSAGE_REACTION_ADD, reaction, user);
+
+ return { message, reaction, user };
+ }
+}
+
+module.exports = MessageReactionAdd;
diff --git a/node_modules/discord.js/src/client/actions/MessageReactionRemove.js b/node_modules/discord.js/src/client/actions/MessageReactionRemove.js
new file mode 100644
index 0000000..a40aa75
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageReactionRemove.js
@@ -0,0 +1,44 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+/*
+{ user_id: 'id',
+ message_id: 'id',
+ emoji: { name: '�', id: null },
+ channel_id: 'id' } }
+*/
+
+class MessageReactionRemove extends Action {
+ handle(data) {
+ if (!data.emoji) return false;
+
+ const user = this.getUser(data);
+ if (!user) return false;
+
+ // Verify channel
+ const channel = this.getChannel(data);
+ if (!channel || channel.type === 'voice') return false;
+
+ // Verify message
+ const message = this.getMessage(data, channel);
+ if (!message) return false;
+
+ // Verify reaction
+ const reaction = this.getReaction(data, message, user);
+ if (!reaction) return false;
+ reaction._remove(user);
+ /**
+ * Emitted whenever a reaction is removed from a cached message.
+ * @event Client#messageReactionRemove
+ * @param {MessageReaction} messageReaction The reaction object
+ * @param {User} user The user whose emoji or reaction emoji was removed
+ */
+ this.client.emit(Events.MESSAGE_REACTION_REMOVE, reaction, user);
+
+ return { message, reaction, user };
+ }
+}
+
+module.exports = MessageReactionRemove;
diff --git a/node_modules/discord.js/src/client/actions/MessageReactionRemoveAll.js b/node_modules/discord.js/src/client/actions/MessageReactionRemoveAll.js
new file mode 100644
index 0000000..14b79bf
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageReactionRemoveAll.js
@@ -0,0 +1,29 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class MessageReactionRemoveAll extends Action {
+ handle(data) {
+ // Verify channel
+ const channel = this.getChannel(data);
+ if (!channel || channel.type === 'voice') return false;
+
+ // Verify message
+ const message = this.getMessage(data, channel);
+ if (!message) return false;
+
+ message.reactions.cache.clear();
+ this.client.emit(Events.MESSAGE_REACTION_REMOVE_ALL, message);
+
+ return { message };
+ }
+}
+
+/**
+ * Emitted whenever all reactions are removed from a cached message.
+ * @event Client#messageReactionRemoveAll
+ * @param {Message} message The message the reactions were removed from
+ */
+
+module.exports = MessageReactionRemoveAll;
diff --git a/node_modules/discord.js/src/client/actions/MessageReactionRemoveEmoji.js b/node_modules/discord.js/src/client/actions/MessageReactionRemoveEmoji.js
new file mode 100644
index 0000000..143702c
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageReactionRemoveEmoji.js
@@ -0,0 +1,28 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class MessageReactionRemoveEmoji extends Action {
+ handle(data) {
+ const channel = this.getChannel(data);
+ if (!channel || channel.type === 'voice') return false;
+
+ const message = this.getMessage(data, channel);
+ if (!message) return false;
+
+ const reaction = this.getReaction(data, message);
+ if (!reaction) return false;
+ if (!message.partial) message.reactions.cache.delete(reaction.emoji.id || reaction.emoji.name);
+
+ /**
+ * Emitted when a bot removes an emoji reaction from a cached message.
+ * @event Client#messageReactionRemoveEmoji
+ * @param {MessageReaction} reaction The reaction that was removed
+ */
+ this.client.emit(Events.MESSAGE_REACTION_REMOVE_EMOJI, reaction);
+ return { reaction };
+ }
+}
+
+module.exports = MessageReactionRemoveEmoji;
diff --git a/node_modules/discord.js/src/client/actions/MessageUpdate.js b/node_modules/discord.js/src/client/actions/MessageUpdate.js
new file mode 100644
index 0000000..07e2aac
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageUpdate.js
@@ -0,0 +1,24 @@
+'use strict';
+
+const Action = require('./Action');
+
+class MessageUpdateAction extends Action {
+ handle(data) {
+ const channel = this.getChannel(data);
+ if (channel) {
+ const { id, channel_id, guild_id, author, timestamp, type } = data;
+ const message = this.getMessage({ id, channel_id, guild_id, author, timestamp, type }, channel);
+ if (message) {
+ message.patch(data);
+ return {
+ old: message._edits[0],
+ updated: message,
+ };
+ }
+ }
+
+ return {};
+ }
+}
+
+module.exports = MessageUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/PresenceUpdate.js b/node_modules/discord.js/src/client/actions/PresenceUpdate.js
new file mode 100644
index 0000000..f74fbeb
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/PresenceUpdate.js
@@ -0,0 +1,44 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class PresenceUpdateAction extends Action {
+ handle(data) {
+ let user = this.client.users.cache.get(data.user.id);
+ if (!user && data.user.username) user = this.client.users.add(data.user);
+ if (!user) return;
+
+ if (data.user && data.user.username) {
+ if (!user.equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
+ }
+
+ const guild = this.client.guilds.cache.get(data.guild_id);
+ if (!guild) return;
+
+ let oldPresence = guild.presences.cache.get(user.id);
+ if (oldPresence) oldPresence = oldPresence._clone();
+ let member = guild.members.cache.get(user.id);
+ if (!member && data.status !== 'offline') {
+ member = guild.members.add({
+ user,
+ roles: data.roles,
+ deaf: false,
+ mute: false,
+ });
+ this.client.emit(Events.GUILD_MEMBER_AVAILABLE, member);
+ }
+ guild.presences.add(Object.assign(data, { guild }));
+ if (member && this.client.listenerCount(Events.PRESENCE_UPDATE)) {
+ /**
+ * Emitted whenever a guild member's presence (e.g. status, activity) is changed.
+ * @event Client#presenceUpdate
+ * @param {?Presence} oldPresence The presence before the update, if one at all
+ * @param {Presence} newPresence The presence after the update
+ */
+ this.client.emit(Events.PRESENCE_UPDATE, oldPresence, member.presence);
+ }
+ }
+}
+
+module.exports = PresenceUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/UserUpdate.js b/node_modules/discord.js/src/client/actions/UserUpdate.js
new file mode 100644
index 0000000..7279ca7
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/UserUpdate.js
@@ -0,0 +1,34 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class UserUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const newUser = client.users.cache.get(data.id);
+ const oldUser = newUser._update(data);
+
+ if (!oldUser.equals(newUser)) {
+ /**
+ * Emitted whenever a user's details (e.g. username) are changed.
+ * @event Client#userUpdate
+ * @param {User} oldUser The user before the update
+ * @param {User} newUser The user after the update
+ */
+ client.emit(Events.USER_UPDATE, oldUser, newUser);
+ return {
+ old: oldUser,
+ updated: newUser,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+module.exports = UserUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/VoiceStateUpdate.js b/node_modules/discord.js/src/client/actions/VoiceStateUpdate.js
new file mode 100644
index 0000000..6f2ee9d
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/VoiceStateUpdate.js
@@ -0,0 +1,44 @@
+'use strict';
+
+const Action = require('./Action');
+const VoiceState = require('../../structures/VoiceState');
+const { Events } = require('../../util/Constants');
+
+class VoiceStateUpdate extends Action {
+ handle(data) {
+ const client = this.client;
+ const guild = client.guilds.cache.get(data.guild_id);
+ if (guild) {
+ // Update the state
+ const oldState = guild.voiceStates.cache.has(data.user_id)
+ ? guild.voiceStates.cache.get(data.user_id)._clone()
+ : new VoiceState(guild, { user_id: data.user_id });
+
+ const newState = guild.voiceStates.add(data);
+
+ // Get the member
+ let member = guild.members.cache.get(data.user_id);
+ if (member && data.member) {
+ member._patch(data.member);
+ } else if (data.member && data.member.user && data.member.joined_at) {
+ member = guild.members.add(data.member);
+ }
+
+ // Emit event
+ if (member && member.user.id === client.user.id) {
+ client.emit('debug', `[VOICE] received voice state update: ${JSON.stringify(data)}`);
+ client.voice.onVoiceStateUpdate(data);
+ }
+
+ /**
+ * Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.
+ * @event Client#voiceStateUpdate
+ * @param {VoiceState} oldState The voice state before the update
+ * @param {VoiceState} newState The voice state after the update
+ */
+ client.emit(Events.VOICE_STATE_UPDATE, oldState, newState);
+ }
+ }
+}
+
+module.exports = VoiceStateUpdate;
diff --git a/node_modules/discord.js/src/client/actions/WebhooksUpdate.js b/node_modules/discord.js/src/client/actions/WebhooksUpdate.js
new file mode 100644
index 0000000..fdf9c56
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/WebhooksUpdate.js
@@ -0,0 +1,19 @@
+'use strict';
+
+const Action = require('./Action');
+const { Events } = require('../../util/Constants');
+
+class WebhooksUpdate extends Action {
+ handle(data) {
+ const client = this.client;
+ const channel = client.channels.cache.get(data.channel_id);
+ /**
+ * Emitted whenever a guild text channel has its webhooks changed.
+ * @event Client#webhookUpdate
+ * @param {TextChannel} channel The channel that had a webhook update
+ */
+ if (channel) client.emit(Events.WEBHOOKS_UPDATE, channel);
+ }
+}
+
+module.exports = WebhooksUpdate;