Skip to content

Commit

Permalink
better code
Browse files Browse the repository at this point in the history
  • Loading branch information
eartharoid committed Aug 25, 2020
1 parent 22bfbf2 commit d3fa3f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/events/messageUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 10 additions & 12 deletions src/modules/archive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand Down

0 comments on commit d3fa3f3

Please sign in to comment.