aboutsummaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/discord.js/src/client/actions')
-rw-r--r--node_modules/discord.js/src/client/actions/Action.js23
-rw-r--r--node_modules/discord.js/src/client/actions/ActionsManager.js38
-rw-r--r--node_modules/discord.js/src/client/actions/ChannelCreate.js13
-rw-r--r--node_modules/discord.js/src/client/actions/ChannelDelete.js31
-rw-r--r--node_modules/discord.js/src/client/actions/ChannelUpdate.js34
-rw-r--r--node_modules/discord.js/src/client/actions/GuildBanRemove.js13
-rw-r--r--node_modules/discord.js/src/client/actions/GuildDelete.js51
-rw-r--r--node_modules/discord.js/src/client/actions/GuildEmojiCreate.js18
-rw-r--r--node_modules/discord.js/src/client/actions/GuildEmojiDelete.js18
-rw-r--r--node_modules/discord.js/src/client/actions/GuildEmojiUpdate.js15
-rw-r--r--node_modules/discord.js/src/client/actions/GuildMemberGet.js12
-rw-r--r--node_modules/discord.js/src/client/actions/GuildMemberRemove.js49
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRoleCreate.js32
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRoleDelete.js46
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRoleUpdate.js41
-rw-r--r--node_modules/discord.js/src/client/actions/GuildRolesPositionUpdate.js23
-rw-r--r--node_modules/discord.js/src/client/actions/GuildSync.js27
-rw-r--r--node_modules/discord.js/src/client/actions/GuildUpdate.js34
-rw-r--r--node_modules/discord.js/src/client/actions/MessageCreate.js40
-rw-r--r--node_modules/discord.js/src/client/actions/MessageDelete.js40
-rw-r--r--node_modules/discord.js/src/client/actions/MessageDeleteBulk.js24
-rw-r--r--node_modules/discord.js/src/client/actions/MessageReactionAdd.js43
-rw-r--r--node_modules/discord.js/src/client/actions/MessageReactionRemove.js43
-rw-r--r--node_modules/discord.js/src/client/actions/MessageReactionRemoveAll.js25
-rw-r--r--node_modules/discord.js/src/client/actions/MessageUpdate.js43
-rw-r--r--node_modules/discord.js/src/client/actions/UserGet.js13
-rw-r--r--node_modules/discord.js/src/client/actions/UserNoteUpdate.js30
-rw-r--r--node_modules/discord.js/src/client/actions/UserUpdate.js33
28 files changed, 852 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..8fdadc9
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/Action.js
@@ -0,0 +1,23 @@
+/*
+
+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;
+ }
+}
+
+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..ac95aa7
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ActionsManager.js
@@ -0,0 +1,38 @@
+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('./ChannelCreate'));
+ this.register(require('./ChannelDelete'));
+ this.register(require('./ChannelUpdate'));
+ this.register(require('./GuildDelete'));
+ this.register(require('./GuildUpdate'));
+ this.register(require('./GuildMemberGet'));
+ this.register(require('./GuildMemberRemove'));
+ this.register(require('./GuildBanRemove'));
+ this.register(require('./GuildRoleCreate'));
+ this.register(require('./GuildRoleDelete'));
+ this.register(require('./GuildRoleUpdate'));
+ this.register(require('./UserGet'));
+ this.register(require('./UserUpdate'));
+ this.register(require('./UserNoteUpdate'));
+ this.register(require('./GuildSync'));
+ this.register(require('./GuildEmojiCreate'));
+ this.register(require('./GuildEmojiDelete'));
+ this.register(require('./GuildEmojiUpdate'));
+ this.register(require('./GuildRolesPositionUpdate'));
+ }
+
+ 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..dc47041
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ChannelCreate.js
@@ -0,0 +1,13 @@
+const Action = require('./Action');
+
+class ChannelCreateAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const channel = client.dataManager.newChannel(data);
+ 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..7b847ef
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ChannelDelete.js
@@ -0,0 +1,31 @@
+const Action = require('./Action');
+
+class ChannelDeleteAction extends Action {
+ constructor(client) {
+ super(client);
+ this.deleted = new Map();
+ }
+
+ handle(data) {
+ const client = this.client;
+
+ let channel = client.channels.get(data.id);
+ if (channel) {
+ client.dataManager.killChannel(channel);
+ this.deleted.set(channel.id, channel);
+ this.scheduleForDeletion(channel.id);
+ } else {
+ channel = this.deleted.get(data.id) || null;
+ }
+
+ return {
+ channel,
+ };
+ }
+
+ scheduleForDeletion(id) {
+ this.client.setTimeout(() => this.deleted.delete(id), this.client.options.restWsBridgeTimeout);
+ }
+}
+
+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..df50ed4
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/ChannelUpdate.js
@@ -0,0 +1,34 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+const cloneObject = require('../../util/CloneObject');
+
+class ChannelUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const channel = client.channels.get(data.id);
+ if (channel) {
+ const oldChannel = cloneObject(channel);
+ channel.setup(data);
+ client.emit(Constants.Events.CHANNEL_UPDATE, oldChannel, channel);
+ return {
+ old: oldChannel,
+ updated: channel,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+/**
+ * Emitted whenever a channel is updated - e.g. name change, topic change.
+ * @event Client#channelUpdate
+ * @param {Channel} oldChannel The channel before the update
+ * @param {Channel} newChannel The channel after the update
+ */
+
+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..0276a52
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildBanRemove.js
@@ -0,0 +1,13 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+
+class GuildBanRemove extends Action {
+ handle(data) {
+ const client = this.client;
+ const guild = client.guilds.get(data.guild_id);
+ const user = client.dataManager.newUser(data.user);
+ if (guild && user) client.emit(Constants.Events.GUILD_BAN_REMOVE, guild, user);
+ }
+}
+
+module.exports = GuildBanRemove;
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..1214263
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildDelete.js
@@ -0,0 +1,51 @@
+const Action = require('./Action');
+const Constants = 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.get(data.id);
+ if (guild) {
+ if (guild.available && data.unavailable) {
+ // guild is unavailable
+ guild.available = false;
+ client.emit(Constants.Events.GUILD_UNAVAILABLE, guild);
+
+ // stops the GuildDelete packet thinking a guild was actually deleted,
+ // handles emitting of event itself
+ return {
+ guild: null,
+ };
+ }
+
+ // delete guild
+ client.guilds.delete(guild.id);
+ 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);
+ }
+}
+
+/**
+ * Emitted whenever a guild becomes unavailable, likely due to a server outage.
+ * @event Client#guildUnavailable
+ * @param {Guild} guild The guild that has become unavailable.
+ */
+
+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..5df1ced
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildEmojiCreate.js
@@ -0,0 +1,18 @@
+const Action = require('./Action');
+
+class GuildEmojiCreateAction extends Action {
+ handle(guild, createdEmoji) {
+ const client = this.client;
+ const emoji = client.dataManager.newEmoji(createdEmoji, guild);
+ return {
+ emoji,
+ };
+ }
+}
+
+/**
+ * Emitted whenever a custom emoji is created in a guild
+ * @event Client#emojiCreate
+ * @param {Emoji} emoji The emoji that was created.
+ */
+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..8cfa205
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildEmojiDelete.js
@@ -0,0 +1,18 @@
+const Action = require('./Action');
+
+class GuildEmojiDeleteAction extends Action {
+ handle(emoji) {
+ const client = this.client;
+ client.dataManager.killEmoji(emoji);
+ return {
+ emoji,
+ };
+ }
+}
+
+/**
+ * Emitted whenever a custom guild emoji is deleted
+ * @event Client#emojiDelete
+ * @param {Emoji} emoji The emoji that was deleted.
+ */
+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..94bfa24
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildEmojiUpdate.js
@@ -0,0 +1,15 @@
+const Action = require('./Action');
+
+class GuildEmojiUpdateAction extends Action {
+ handle(oldEmoji, newEmoji) {
+ this.client.dataManager.updateEmoji(oldEmoji, newEmoji);
+ }
+}
+
+/**
+ * Emitted whenever a custom guild emoji is updated
+ * @event Client#emojiUpdate
+ * @param {Emoji} oldEmoji The old emoji
+ * @param {Emoji} newEmoji The new emoji
+ */
+module.exports = GuildEmojiUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/GuildMemberGet.js b/node_modules/discord.js/src/client/actions/GuildMemberGet.js
new file mode 100644
index 0000000..b00fa0f
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildMemberGet.js
@@ -0,0 +1,12 @@
+const Action = require('./Action');
+
+class GuildMemberGetAction extends Action {
+ handle(guild, data) {
+ const member = guild._addMember(data, false);
+ return {
+ member,
+ };
+ }
+}
+
+module.exports = GuildMemberGetAction;
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..d68b8b5
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildMemberRemove.js
@@ -0,0 +1,49 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+
+class GuildMemberRemoveAction extends Action {
+ constructor(client) {
+ super(client);
+ this.deleted = new Map();
+ }
+
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.get(data.guild_id);
+ if (guild) {
+ let member = guild.members.get(data.user.id);
+ if (member) {
+ guild.memberCount--;
+ guild._removeMember(member);
+ this.deleted.set(guild.id + data.user.id, member);
+ if (client.status === Constants.Status.READY) client.emit(Constants.Events.GUILD_MEMBER_REMOVE, member);
+ this.scheduleForDeletion(guild.id, data.user.id);
+ } else {
+ member = this.deleted.get(guild.id + data.user.id) || null;
+ }
+
+ return {
+ guild,
+ member,
+ };
+ }
+
+ return {
+ guild,
+ member: null,
+ };
+ }
+
+ scheduleForDeletion(guildID, userID) {
+ this.client.setTimeout(() => this.deleted.delete(guildID + userID), this.client.options.restWsBridgeTimeout);
+ }
+}
+
+/**
+ * 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.
+ */
+
+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..82ea19a
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRoleCreate.js
@@ -0,0 +1,32 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+const Role = require('../../structures/Role');
+
+class GuildRoleCreate extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.get(data.guild_id);
+ if (guild) {
+ const already = guild.roles.has(data.role.id);
+ const role = new Role(guild, data.role);
+ guild.roles.set(role.id, role);
+ if (!already) client.emit(Constants.Events.GUILD_ROLE_CREATE, role);
+ return {
+ role,
+ };
+ }
+
+ return {
+ role: null,
+ };
+ }
+}
+
+/**
+ * Emitted whenever a role is created.
+ * @event Client#roleCreate
+ * @param {Role} role The role that was created.
+ */
+
+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..eeaa1e9
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRoleDelete.js
@@ -0,0 +1,46 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+
+class GuildRoleDeleteAction extends Action {
+ constructor(client) {
+ super(client);
+ this.deleted = new Map();
+ }
+
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.get(data.guild_id);
+ if (guild) {
+ let role = guild.roles.get(data.role_id);
+ if (role) {
+ guild.roles.delete(data.role_id);
+ this.deleted.set(guild.id + data.role_id, role);
+ this.scheduleForDeletion(guild.id, data.role_id);
+ client.emit(Constants.Events.GUILD_ROLE_DELETE, role);
+ } else {
+ role = this.deleted.get(guild.id + data.role_id) || null;
+ }
+
+ return {
+ role,
+ };
+ }
+
+ return {
+ role: null,
+ };
+ }
+
+ scheduleForDeletion(guildID, roleID) {
+ this.client.setTimeout(() => this.deleted.delete(guildID + roleID), this.client.options.restWsBridgeTimeout);
+ }
+}
+
+/**
+ * Emitted whenever a guild role is deleted.
+ * @event Client#roleDelete
+ * @param {Role} role The role that was deleted.
+ */
+
+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..8270517
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRoleUpdate.js
@@ -0,0 +1,41 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+const cloneObject = require('../../util/CloneObject');
+
+class GuildRoleUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.get(data.guild_id);
+ if (guild) {
+ const roleData = data.role;
+ let oldRole = null;
+
+ const role = guild.roles.get(roleData.id);
+ if (role) {
+ oldRole = cloneObject(role);
+ role.setup(data.role);
+ client.emit(Constants.Events.GUILD_ROLE_UPDATE, oldRole, role);
+ }
+
+ return {
+ old: oldRole,
+ updated: role,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+/**
+ * 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.
+ */
+
+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..a95c923
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildRolesPositionUpdate.js
@@ -0,0 +1,23 @@
+const Action = require('./Action');
+
+class GuildRolesPositionUpdate extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.get(data.guild_id);
+ if (guild) {
+ for (const partialRole of data.roles) {
+ const role = guild.roles.get(partialRole.id);
+ if (role) {
+ role.position = partialRole.position;
+ }
+ }
+ }
+
+ return {
+ guild,
+ };
+ }
+}
+
+module.exports = GuildRolesPositionUpdate;
diff --git a/node_modules/discord.js/src/client/actions/GuildSync.js b/node_modules/discord.js/src/client/actions/GuildSync.js
new file mode 100644
index 0000000..7b94ec8
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildSync.js
@@ -0,0 +1,27 @@
+const Action = require('./Action');
+
+class GuildSync extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.get(data.id);
+ if (guild) {
+ data.presences = data.presences || [];
+ for (const presence of data.presences) {
+ guild._setPresence(presence.user.id, presence);
+ }
+
+ data.members = data.members || [];
+ for (const syncMember of data.members) {
+ const member = guild.members.get(syncMember.user.id);
+ if (member) {
+ guild._updateMember(member, syncMember);
+ } else {
+ guild._addMember(syncMember, false);
+ }
+ }
+ }
+ }
+}
+
+module.exports = GuildSync;
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..efda7f7
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/GuildUpdate.js
@@ -0,0 +1,34 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+const cloneObject = require('../../util/CloneObject');
+
+class GuildUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const guild = client.guilds.get(data.id);
+ if (guild) {
+ const oldGuild = cloneObject(guild);
+ guild.setup(data);
+ client.emit(Constants.Events.GUILD_UPDATE, oldGuild, guild);
+ return {
+ old: oldGuild,
+ updated: guild,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+/**
+ * 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.
+ */
+
+module.exports = GuildUpdateAction;
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..00fc1e9
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageCreate.js
@@ -0,0 +1,40 @@
+const Action = require('./Action');
+const Message = require('../../structures/Message');
+
+class MessageCreateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const channel = client.channels.get((data instanceof Array ? data[0] : data).channel_id);
+ const user = client.users.get((data instanceof Array ? data[0] : data).author.id);
+ if (channel) {
+ const member = channel.guild ? channel.guild.member(user) : null;
+ if (data instanceof Array) {
+ const messages = new Array(data.length);
+ for (let i = 0; i < data.length; i++) {
+ messages[i] = channel._cacheMessage(new Message(channel, data[i], client));
+ }
+ channel.lastMessageID = messages[messages.length - 1].id;
+ if (user) user.lastMessageID = messages[messages.length - 1].id;
+ if (member) member.lastMessageID = messages[messages.length - 1].id;
+ return {
+ messages,
+ };
+ } else {
+ const message = channel._cacheMessage(new Message(channel, data, client));
+ channel.lastMessageID = data.id;
+ if (user) user.lastMessageID = data.id;
+ if (member) member.lastMessageID = data.id;
+ return {
+ message,
+ };
+ }
+ }
+
+ return {
+ message: null,
+ };
+ }
+}
+
+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..beb8050
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageDelete.js
@@ -0,0 +1,40 @@
+const Action = require('./Action');
+
+class MessageDeleteAction extends Action {
+ constructor(client) {
+ super(client);
+ this.deleted = new Map();
+ }
+
+ handle(data) {
+ const client = this.client;
+
+ const channel = client.channels.get(data.channel_id);
+ if (channel) {
+ let message = channel.messages.get(data.id);
+
+ if (message) {
+ channel.messages.delete(message.id);
+ this.deleted.set(channel.id + message.id, message);
+ this.scheduleForDeletion(channel.id, message.id);
+ } else {
+ message = this.deleted.get(channel.id + data.id) || null;
+ }
+
+ return {
+ message,
+ };
+ }
+
+ return {
+ message: null,
+ };
+ }
+
+ scheduleForDeletion(channelID, messageID) {
+ this.client.setTimeout(() => this.deleted.delete(channelID + messageID),
+ this.client.options.restWsBridgeTimeout);
+ }
+}
+
+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..6a12ef1
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageDeleteBulk.js
@@ -0,0 +1,24 @@
+const Action = require('./Action');
+const Collection = require('../../util/Collection');
+const Constants = require('../../util/Constants');
+
+class MessageDeleteBulkAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const channel = client.channels.get(data.channel_id);
+
+ const ids = data.ids;
+ const messages = new Collection();
+ for (const id of ids) {
+ const message = channel.messages.get(id);
+ if (message) messages.set(message.id, message);
+ }
+
+ if (messages.size > 0) client.emit(Constants.Events.MESSAGE_BULK_DELETE, messages);
+ return {
+ messages,
+ };
+ }
+}
+
+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..f57ec2e
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageReactionAdd.js
@@ -0,0 +1,43 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+
+/*
+{ user_id: 'id',
+ message_id: 'id',
+ emoji: { name: '�', id: null },
+ channel_id: 'id' } }
+*/
+
+class MessageReactionAdd extends Action {
+ handle(data) {
+ const user = this.client.users.get(data.user_id);
+ if (!user) return false;
+
+ const channel = this.client.channels.get(data.channel_id);
+ if (!channel || channel.type === 'voice') return false;
+
+ const message = channel.messages.get(data.message_id);
+ if (!message) return false;
+
+ if (!data.emoji) return false;
+
+ const reaction = message._addReaction(data.emoji, user);
+
+ if (reaction) {
+ this.client.emit(Constants.Events.MESSAGE_REACTION_ADD, reaction, user);
+ }
+
+ return {
+ message,
+ reaction,
+ user,
+ };
+ }
+}
+/**
+ * Emitted whenever a reaction is added to a message.
+ * @event Client#messageReactionAdd
+ * @param {MessageReaction} messageReaction The reaction object.
+ * @param {User} user The user that applied the emoji or reaction emoji.
+ */
+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..98a958d
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageReactionRemove.js
@@ -0,0 +1,43 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+
+/*
+{ user_id: 'id',
+ message_id: 'id',
+ emoji: { name: '�', id: null },
+ channel_id: 'id' } }
+*/
+
+class MessageReactionRemove extends Action {
+ handle(data) {
+ const user = this.client.users.get(data.user_id);
+ if (!user) return false;
+
+ const channel = this.client.channels.get(data.channel_id);
+ if (!channel || channel.type === 'voice') return false;
+
+ const message = channel.messages.get(data.message_id);
+ if (!message) return false;
+
+ if (!data.emoji) return false;
+
+ const reaction = message._removeReaction(data.emoji, user);
+
+ if (reaction) {
+ this.client.emit(Constants.Events.MESSAGE_REACTION_REMOVE, reaction, user);
+ }
+
+ return {
+ message,
+ reaction,
+ user,
+ };
+ }
+}
+/**
+ * Emitted whenever a reaction is removed from a message.
+ * @event Client#messageReactionRemove
+ * @param {MessageReaction} messageReaction The reaction object.
+ * @param {User} user The user that removed the emoji or reaction emoji.
+ */
+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..f35b785
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageReactionRemoveAll.js
@@ -0,0 +1,25 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+
+class MessageReactionRemoveAll extends Action {
+ handle(data) {
+ const channel = this.client.channels.get(data.channel_id);
+ if (!channel || channel.type === 'voice') return false;
+
+ const message = channel.messages.get(data.message_id);
+ if (!message) return false;
+
+ message._clearReactions();
+ this.client.emit(Constants.Events.MESSAGE_REACTION_REMOVE_ALL, message);
+
+ return {
+ message,
+ };
+ }
+}
+/**
+ * Emitted whenever all reactions are removed from a message.
+ * @event Client#messageReactionRemoveAll
+ * @param {MessageReaction} messageReaction The reaction object.
+ */
+module.exports = MessageReactionRemoveAll;
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..a62c332
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/MessageUpdate.js
@@ -0,0 +1,43 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+const cloneObject = require('../../util/CloneObject');
+
+class MessageUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const channel = client.channels.get(data.channel_id);
+ if (channel) {
+ const message = channel.messages.get(data.id);
+ if (message) {
+ const oldMessage = cloneObject(message);
+ message.patch(data);
+ message._edits.unshift(oldMessage);
+ client.emit(Constants.Events.MESSAGE_UPDATE, oldMessage, message);
+ return {
+ old: oldMessage,
+ updated: message,
+ };
+ }
+
+ return {
+ old: message,
+ updated: message,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+/**
+ * Emitted whenever a message is updated - e.g. embed or content change.
+ * @event Client#messageUpdate
+ * @param {Message} oldMessage The message before the update.
+ * @param {Message} newMessage The message after the update.
+ */
+
+module.exports = MessageUpdateAction;
diff --git a/node_modules/discord.js/src/client/actions/UserGet.js b/node_modules/discord.js/src/client/actions/UserGet.js
new file mode 100644
index 0000000..65e7c95
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/UserGet.js
@@ -0,0 +1,13 @@
+const Action = require('./Action');
+
+class UserGetAction extends Action {
+ handle(data) {
+ const client = this.client;
+ const user = client.dataManager.newUser(data);
+ return {
+ user,
+ };
+ }
+}
+
+module.exports = UserGetAction;
diff --git a/node_modules/discord.js/src/client/actions/UserNoteUpdate.js b/node_modules/discord.js/src/client/actions/UserNoteUpdate.js
new file mode 100644
index 0000000..4c2cc21
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/UserNoteUpdate.js
@@ -0,0 +1,30 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+
+class UserNoteUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ const oldNote = client.user.notes.get(data.id);
+ const note = data.note.length ? data.note : null;
+
+ client.user.notes.set(data.id, note);
+
+ client.emit(Constants.Events.USER_NOTE_UPDATE, data.id, oldNote, note);
+
+ return {
+ old: oldNote,
+ updated: note,
+ };
+ }
+}
+
+/**
+ * Emitted whenever a note is updated.
+ * @event Client#userNoteUpdate
+ * @param {User} user The user the note belongs to
+ * @param {string} oldNote The note content before the update
+ * @param {string} newNote The note content after the update
+ */
+
+module.exports = UserNoteUpdateAction;
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..b361eca
--- /dev/null
+++ b/node_modules/discord.js/src/client/actions/UserUpdate.js
@@ -0,0 +1,33 @@
+const Action = require('./Action');
+const Constants = require('../../util/Constants');
+const cloneObject = require('../../util/CloneObject');
+
+class UserUpdateAction extends Action {
+ handle(data) {
+ const client = this.client;
+
+ if (client.user) {
+ if (client.user.equals(data)) {
+ return {
+ old: client.user,
+ updated: client.user,
+ };
+ }
+
+ const oldUser = cloneObject(client.user);
+ client.user.patch(data);
+ client.emit(Constants.Events.USER_UPDATE, oldUser, client.user);
+ return {
+ old: oldUser,
+ updated: client.user,
+ };
+ }
+
+ return {
+ old: null,
+ updated: null,
+ };
+ }
+}
+
+module.exports = UserUpdateAction;