make case insensitive

This commit is contained in:
loicbersier 2019-08-21 20:03:29 +02:00
parent 2e392da2f6
commit a05223a508
2 changed files with 6 additions and 6 deletions

View file

@ -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');
}

View file

@ -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);