diff --git a/structure/client/components/observers/GuildLogging.js b/structure/client/components/observers/GuildLogging.js index 5dee8ed..7f5e96d 100644 --- a/structure/client/components/observers/GuildLogging.js +++ b/structure/client/components/observers/GuildLogging.js @@ -1,8 +1,8 @@ +/* eslint-disable no-labels */ const { MessageAttachment, WebhookClient } = require('discord.js'); const { Observer } = require('../../../interfaces/'); const { Util, Constants: { EmbedLimits } } = require('../../../../util'); -const { inspect } = require('util'); const { stripIndents } = require('common-tags'); const moment = require('moment'); @@ -149,9 +149,8 @@ class GuildLogger extends Observer { const uploaded = []; const upload = async (files) => { - const attachmentMessage = await this.attachmentWebhook.send(null, files).catch((error) => console.error(error)); + const attachmentMessage = await this.attachmentWebhook.send(null, files).catch((error) => this.client.logger.error(error)); attachmentMessage.attachments.map((a) => uploaded.push(`[${a.filename} (${(a.size/CONSTANTS.IMAGES.MB_DIVIDER).toFixed(2)}mb)](${a.url})`)); - console.log(attachmentMessage.attachments); }; for(const file of files) { @@ -168,8 +167,6 @@ class GuildLogger extends Observer { await upload(currentFiles); } - console.log(uploaded.length); - if(uploaded.length > 0) { embed.description += `\n\n**${uploadedFiles.length > 0 ? 'Additional ' : ''}Attachment${uploaded.length > 1 ? 's' : ''}:** ${uploaded.join(', ')}`; } @@ -219,18 +216,20 @@ class GuildLogger extends Observer { const fields = []; //Compile messages into fields that can be compiled into embeds - messages: //Oldest messages first + messageLoop: //Oldest messages first for (const message of messages.array().sort((a, b) => b.createdTimestamp - a.createdTimestamp)) { let { member } = message; const { content, author, id } = message; - if (author.bot) continue messages; - if (!member || member.partial) member = await guild.members.fetch(message.author.id).catch(() => { return false }); + if (author.bot) continue; + if (!member || member.partial) member = await guild.members.fetch(message.author.id).catch(() => { + return false; + }); if (member && member.roles.cache.size) { const roles = member.roles.cache.map((role) => role.id); for (const role of roles) { - if (ignoredRoles.includes(role)) continue messages; + if (ignoredRoles.includes(role)) continue messageLoop; } } @@ -243,8 +242,8 @@ class GuildLogger extends Observer { }); if (content && content.length > cutOff) fields.push({ - name: '\u200b', - value: content.substring(cutOff) + name: '\u200b', + value: content.substring(cutOff) }); } @@ -252,7 +251,7 @@ class GuildLogger extends Observer { //Compile embeds const embedCutoff = EmbedLimits.embed - 100; const embeds = []; - let embed = {// title gets set later + const embed = { // title gets set later fields: [], color: CONSTANTS.COLORS.RED }; @@ -368,6 +367,7 @@ class GuildLogger extends Observer { //Original content embed.fields.push({ name: oldMessage.format('MSGLOG_EDIT_OLD'), + // eslint-disable-next-line no-nested-ternary value: oldCon.length > 1024 ? oldCon.substring(0, 1021) + '...' : oldCon.length ? oldCon : '\u200b' }); if(oldCon.length > 1024) embed.fields.push({ @@ -389,7 +389,6 @@ class GuildLogger extends Observer { await hook.send({ embeds: [embed] }).catch((err) => { this.client.logger.error('Error in message edit:\n' + err.stack); - this.client.logger.error(perms.toArray()); }); }