From 88c31d9433dc5a05d962edec91c23cc8d76d96a5 Mon Sep 17 00:00:00 2001 From: loicbersier Date: Wed, 21 Aug 2019 22:17:56 +0200 Subject: [PATCH] Remove zero width space --- event/listeners/message.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/event/listeners/message.js b/event/listeners/message.js index bdac2d9..2bbfc4c 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -21,9 +21,12 @@ class messageListener extends Listener { // Banned words - const bannedWords = await BannedWords.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content), Sequelize.Op.ne, 0), serverID: message.guild.id}}); + const bannedWords = await BannedWords.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content.replace(/\u200B/g, '')), Sequelize.Op.ne, 0), serverID: message.guild.id}}); if (bannedWords[0].get('word')) { let censoredMessage = message.content.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, ''); + // Remove zero width space character + censoredMessage = censoredMessage.replace(/\u200B/g, ''); + for (let i = 0; i < bannedWords.length; i++) { censoredMessage = censoredMessage.replace(bannedWords[i].get('word'), '█'.repeat(bannedWords[i].get('word').length)); }