From d3fa3f3e6834a125f2923b43d1478366eb062bd3 Mon Sep 17 00:00:00 2001 From: "Isaac (eartharoid)" Date: Tue, 25 Aug 2020 23:53:35 +0100 Subject: [PATCH] better code --- src/events/messageUpdate.js | 3 +-- src/modules/archive.js | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/events/messageUpdate.js b/src/events/messageUpdate.js index e9ca608..fa1f2e1 100644 --- a/src/events/messageUpdate.js +++ b/src/events/messageUpdate.js @@ -38,8 +38,7 @@ module.exports = { let path = `user/transcripts/raw/${n.channel.id}.log`; let embeds = []; for (let embed in n.embeds) - // embeds.push(n.embeds[embed]); // n.embeds[embed].toJSON() - embeds[embed] = { ...n.embeds[embed] }; + embeds.push({ ...n.embeds[embed] }); fs.appendFileSync(path, JSON.stringify({ id: n.id, diff --git a/src/modules/archive.js b/src/modules/archive.js index dc0b8cc..d2ae230 100644 --- a/src/modules/archive.js +++ b/src/modules/archive.js @@ -34,8 +34,7 @@ module.exports.add = (message) => { let embeds = []; for (let embed in message.embeds) - // embeds.push(message.embeds[embed]); // .toJSON() - embeds[embed] = { ...message.embeds[embed] }; + embeds.push({ ...message.embeds[embed] }); // message fs.appendFileSync(raw, JSON.stringify({ @@ -59,16 +58,15 @@ module.exports.add = (message) => { let data = JSON.parse(fs.readFileSync(json)); - if (!data.entities.users[message.author.id]) { - data.entities.users[message.author.id] = { - avatar: message.author.avatarURL(), - username: message.author.username, - discriminator: message.author.discriminator, - displayName: message.member.displayName, - color: m.displayColor === 0 ? null : m.displayColor, - badge: message.author.bot ? 'bot' : null - }; - } + // if (!data.entities.users[message.author.id]) + data.entities.users[message.author.id] = { + avatar: message.author.avatarURL(), + username: message.author.username, + discriminator: message.author.discriminator, + displayName: message.member.displayName, + color: message.member.displayColor === 0 ? null : message.member.displayColor, + badge: message.author.bot ? 'bot' : null + }; // mentions.users message.mentions.members.each(m => data.entities.users[m.id] = { // for mentions