diff --git a/src/events/onMessageUpdate.js b/src/events/onMessageUpdate.js index cdcb268..a8d2f41 100644 --- a/src/events/onMessageUpdate.js +++ b/src/events/onMessageUpdate.js @@ -3,7 +3,7 @@ const { deconstructMention } = require('../enhancedMention'); const { triggerWH, setInMap, MESSAGE_LIMIT } = require('../utils'); -exports.onMessageUpdate = async(botClient, network, channelsCache, msg, oldMsg) => { +exports.onMessageUpdate = async(botClient, network, channelsCache, deleteOnUpdate, msg, oldMsg) => { // !oldMsg = message not cached = don't log the update if (!msg.author || msg.author.bot || !msg.channel.guild || !oldMsg) { return; @@ -39,10 +39,11 @@ exports.onMessageUpdate = async(botClient, network, channelsCache, msg, oldMsg) } messages.push(await triggerWH(botClient, network, channelConfig, cur, msg.author, fullMsg) ); } - const toDelete = channelsCache[msg.channel.id].get(msg.id); - for (const m of toDelete) { - m.delete().catch(); + if (deleteOnUpdate) { + const toDelete = channelsCache[msg.channel.id].get(msg.id); + for (const m of toDelete) { + m.delete().catch(); + } } - setInMap(channelsCache[msg.channel.id], msg.id, messages); }; diff --git a/src/index.js b/src/index.js index 09be257..011b28c 100644 --- a/src/index.js +++ b/src/index.js @@ -31,6 +31,9 @@ exports.setup = function (bot, config) { } ); bot.on('messageCreate', (msg) => onMessageCreate(bot, network, channelsCache, msg) ); - bot.on('messageUpdate', (msg, oldMsg) => onMessageUpdate(bot, network, channelsCache, msg, oldMsg) ); - bot.on('messageDelete', (msg) => onMessageDelete(bot, network, channelsCache, msg) ); + bot.on('messageUpdate', (msg, oldMsg) => onMessageUpdate(bot, network, channelsCache, config.deleteOnUpdate, msg, oldMsg) ); + + if (config.messageDelete) { + bot.on('messageDelete', (msg) => onMessageDelete(bot, network, channelsCache, msg) ); + } };