diff --git a/commands/admin/banword.js b/commands/admin/banword.js index 2f505b9..2c45d61 100644 --- a/commands/admin/banword.js +++ b/commands/admin/banword.js @@ -33,6 +33,7 @@ class BannedWordsCommand extends Command { } async exec(message, args) { + args.word = args.word.replace(/[\u0250-\ue007]/g, ''); const bannedWords = await BannedWords.findOne({where: {word: args.word.toLowerCase(), serverID: message.guild.id}}); if (!bannedWords) { diff --git a/event/listeners/message.js b/event/listeners/message.js index 6ea8065..8495ed4 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -21,11 +21,15 @@ class messageListener extends Listener { // Banned words - 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}}); + const bannedWords = await BannedWords.findAll({where: {word: Sequelize.where(Sequelize.fn('LOCATE', Sequelize.col('word'), message.content.replace(/\u200B/g, '').replace(/[\u0250-\ue007]/g, '')), Sequelize.Op.ne, 0), serverID: message.guild.id}}); if (bannedWords[0].get('word')) { + // Remove accent let censoredMessage = message.content.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, ''); // Remove zero width space character censoredMessage = censoredMessage.replace(/\u200B/g, ''); + // Remove non latin character + censoredMessage = censoredMessage.replace(/[\u0250-\ue007]/g, ''); + for (let i = 0; i < bannedWords.length; i++) { let regex = new RegExp(bannedWords[i].get('word'), 'g'); censoredMessage = censoredMessage.replace(regex, '█'.repeat(bannedWords[i].get('word').length));