From a05223a508c1d33197f2cf65410d6c4b63ced3bc Mon Sep 17 00:00:00 2001 From: loicbersier Date: Wed, 21 Aug 2019 20:03:29 +0200 Subject: [PATCH] make case insensitive --- commands/admin/banword.js | 10 +++++----- event/listeners/message.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/commands/admin/banword.js b/commands/admin/banword.js index 471cb1b0..fcdd8cca 100644 --- a/commands/admin/banword.js +++ b/commands/admin/banword.js @@ -32,15 +32,15 @@ class BannedWordsCommand extends Command { } async exec(message, args) { - const bannedWords = await BannedWords.findOne({where: {word: args.word, serverID: message.guild.id}}); + const bannedWords = await BannedWords.findOne({where: {word: args.word.toLowerCase(), serverID: message.guild.id}}); if (!bannedWords) { - const body = {word: args.word, serverID: message.guild.id}; + const body = {word: args.word.toLowerCase(), serverID: message.guild.id}; await BannedWords.create(body); - return message.channel.send(`The word ${args.word} have been banned`); + return message.channel.send(`The word ${args.word.toLowerCase()} have been banned`); } else if (args.remove && bannedWords) { - BannedWords.destroy({where: {word: args.word, serverID: message.guild.id}}); - return message.channel.send(`The word ${args.word} is no longer banned`); + BannedWords.destroy({where: {word: args.word.toLowerCase(), serverID: message.guild.id}}); + return message.channel.send(`The word ${args.word.toLowerCase()} is no longer banned`); } else { message.channel.send('This word is already banned'); } diff --git a/event/listeners/message.js b/event/listeners/message.js index d1d1c16d..a9a77821 100644 --- a/event/listeners/message.js +++ b/event/listeners/message.js @@ -23,7 +23,7 @@ class messageListener extends Listener { 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}}); if (bannedWords[0].get('word')) { - let censoredMessage = message.content; + let censoredMessage = message.content.toLowerCase(); for (let i = 0; i < bannedWords.length; i++) { censoredMessage = censoredMessage.replace(bannedWords[i].get('word'), '█'.repeat(bannedWords[i].get('word').length)); console.log(censoredMessage);