diff --git a/src/middleware/Logger.js b/src/middleware/Logger.js index 1eef439..9a64bed 100644 --- a/src/middleware/Logger.js +++ b/src/middleware/Logger.js @@ -35,7 +35,10 @@ class Logger { this.manager = manager; this.shardingManager = manager.shardingManager; - this._webhook = new WebhookClient({ url: process.env.ERROR_WEBHOOK_URL }); + const { ERROR_WEBHOOK_URL } = process.env; + if (ERROR_WEBHOOK_URL) this._webhook = new WebhookClient({ url: ERROR_WEBHOOK_URL }); + // eslint-disable-next-line no-console + else console.log('No webhook for logger'); this._options = options; @@ -82,7 +85,7 @@ class Logger { const embed = { color: 0xe88388, timestamp: new Date(), - description: `\`\`\`${message}\`\`\``, + description: `\`\`\`${message.length > 2000 ? message.substring(0, 2000) + ' ... CONTENT CUT OFF' : message}\`\`\``, }; this._webhook.send({ embeds: [embed], username: `ENV: ${process.env.NODE_ENV}` }); diff --git a/src/structure/components/observers/GuildLogging.js b/src/structure/components/observers/GuildLogging.js index f063db7..f488000 100644 --- a/src/structure/components/observers/GuildLogging.js +++ b/src/structure/components/observers/GuildLogging.js @@ -2,6 +2,7 @@ const { MessageAttachment, WebhookClient } = require('discord.js'); const { stripIndents } = require('common-tags'); const moment = require('moment'); +const { inspect } = require('util'); const { Observer } = require('../../interfaces/'); const { Util } = require('../../../utilities'); @@ -606,7 +607,7 @@ class GuildLogger extends Observer { //if(newMessage.content.length > 1024) embed.description += '\n' + oldMessage.format('MSGLOG_EDIT_NEW_CUTOFF'); await hook.send({ embeds: [embed] }).catch((err) => { - this.logger.error('Error in message edit:\n' + err.stack); + this.logger.error('Error in message edit:\n' + err.stack, `\n${inspect(embed)}`); }); }