From 91b8735203c7d79118726250f150017d91d5c4c2 Mon Sep 17 00:00:00 2001 From: TheEssem Date: Sat, 5 Sep 2020 16:33:21 -0500 Subject: [PATCH] Attempt to fix clean replacing empty text --- utils/misc.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/utils/misc.js b/utils/misc.js index a71d249..7bd4528 100644 --- a/utils/misc.js +++ b/utils/misc.js @@ -6,6 +6,10 @@ exports.random = (array) => { return array[Math.floor(Math.random() * array.length)]; }; +const optionalReplace = (token) => { + return token === "" ? "" : ""; +}; + // clean(text) to clean message of any private info or mentions exports.clean = async (text) => { if (text && text.constructor.name == "Promise") @@ -16,16 +20,16 @@ exports.clean = async (text) => { text = text .replace(/`/g, `\`${String.fromCharCode(8203)}`) .replace(/@/g, `@${String.fromCharCode(8203)}`) - .replace(process.env.TOKEN, "") - .replace(process.env.MASHAPE, "") - .replace(process.env.CAT, "") - .replace(process.env.GOOGLE, "") - .replace(process.env.DBL, "") - .replace(process.env.MONGO, "") - .replace(process.env.TWITTER_KEY, "") - .replace(process.env.CONSUMER_SECRET, "") - .replace(process.env.ACCESS_TOKEN, "") - .replace(process.env.ACCESS_SECRET, ""); + .replace(process.env.TOKEN, optionalReplace(process.env.TOKEN)) + .replace(process.env.MASHAPE, optionalReplace(process.env.MASHAPE)) + .replace(process.env.CAT, optionalReplace(process.env.CAT)) + .replace(process.env.GOOGLE, optionalReplace(process.env.GOOGLE)) + .replace(process.env.DBL, optionalReplace(process.env.DBL)) + .replace(process.env.MONGO, optionalReplace(process.env.MONGO)) + .replace(process.env.TWITTER_KEY, optionalReplace(process.env.TWITTER_KEY)) + .replace(process.env.CONSUMER_SECRET, optionalReplace(process.env.CONSUMER_SECRET)) + .replace(process.env.ACCESS_TOKEN, optionalReplace(process.env.ACCESS_TOKEN)) + .replace(process.env.ACCESS_SECRET, optionalReplace(process.env.ACCESS_SECRET)); return text; };