mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
Stop comparing for equality on update events and just emit for performance
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -10,7 +10,7 @@ class ChannelUpdateAction extends Action {
|
|||||||
if (channel) {
|
if (channel) {
|
||||||
const oldChannel = cloneObject(channel);
|
const oldChannel = cloneObject(channel);
|
||||||
channel.setup(data);
|
channel.setup(data);
|
||||||
if (!oldChannel.equals(data)) client.emit(Constants.Events.CHANNEL_UPDATE, oldChannel, channel);
|
client.emit(Constants.Events.CHANNEL_UPDATE, oldChannel, channel);
|
||||||
return {
|
return {
|
||||||
old: oldChannel,
|
old: oldChannel,
|
||||||
updated: channel,
|
updated: channel,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class GuildRoleUpdateAction extends Action {
|
|||||||
let oldRole = null;
|
let oldRole = null;
|
||||||
|
|
||||||
const role = guild.roles.get(roleData.id);
|
const role = guild.roles.get(roleData.id);
|
||||||
if (role && !role.equals(roleData)) {
|
if (role) {
|
||||||
oldRole = cloneObject(role);
|
oldRole = cloneObject(role);
|
||||||
role.setup(data.role);
|
role.setup(data.role);
|
||||||
client.emit(Constants.Events.GUILD_ROLE_UPDATE, guild, oldRole, role);
|
client.emit(Constants.Events.GUILD_ROLE_UPDATE, guild, oldRole, role);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ class GuildUpdateAction extends Action {
|
|||||||
if (guild) {
|
if (guild) {
|
||||||
const oldGuild = cloneObject(guild);
|
const oldGuild = cloneObject(guild);
|
||||||
guild.setup(data);
|
guild.setup(data);
|
||||||
if (!oldGuild.equals(data)) client.emit(Constants.Events.GUILD_UPDATE, oldGuild, guild);
|
client.emit(Constants.Events.GUILD_UPDATE, oldGuild, guild);
|
||||||
return {
|
return {
|
||||||
old: oldGuild,
|
old: oldGuild,
|
||||||
updated: guild,
|
updated: guild,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class MessageUpdateAction extends Action {
|
|||||||
const channel = client.channels.get(data.channel_id);
|
const channel = client.channels.get(data.channel_id);
|
||||||
if (channel) {
|
if (channel) {
|
||||||
const message = channel.messages.get(data.id);
|
const message = channel.messages.get(data.id);
|
||||||
if (message && !message.equals(data, true)) {
|
if (message) {
|
||||||
const oldMessage = cloneObject(message);
|
const oldMessage = cloneObject(message);
|
||||||
message.patch(data);
|
message.patch(data);
|
||||||
message._edits.unshift(oldMessage);
|
message._edits.unshift(oldMessage);
|
||||||
|
|||||||
@@ -22,8 +22,22 @@ client.on('guildMemberAdd', (g, m) => {
|
|||||||
console.log(`${m.user.username} joined ${g.name}`);
|
console.log(`${m.user.username} joined ${g.name}`);
|
||||||
})
|
})
|
||||||
|
|
||||||
client.on('guildMemberUpdate', (g, o, n) => {
|
let c = 0;
|
||||||
console.log(o.nickname, n.nickname);
|
|
||||||
|
client.on('channelUpdate', () => {
|
||||||
|
c++; console.log(c);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('guildMemberUpdate', () => {
|
||||||
|
c++; console.log(c);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('channelPinsUpdate', () => {
|
||||||
|
c++; console.log(c);
|
||||||
|
});
|
||||||
|
|
||||||
|
client.on('presenceUpdate', () => {
|
||||||
|
c++; console.log(c);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on('debug', console.log);
|
client.on('debug', console.log);
|
||||||
|
|||||||
Reference in New Issue
Block a user