forked from Supositware/Haha-Yes
make case insensitive
This commit is contained in:
parent
2e392da2f6
commit
a05223a508
2 changed files with 6 additions and 6 deletions
|
@ -32,15 +32,15 @@ class BannedWordsCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
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) {
|
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);
|
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) {
|
} else if (args.remove && bannedWords) {
|
||||||
BannedWords.destroy({where: {word: args.word, serverID: message.guild.id}});
|
BannedWords.destroy({where: {word: args.word.toLowerCase(), serverID: message.guild.id}});
|
||||||
return message.channel.send(`The word ${args.word} is no longer banned`);
|
return message.channel.send(`The word ${args.word.toLowerCase()} is no longer banned`);
|
||||||
} else {
|
} else {
|
||||||
message.channel.send('This word is already banned');
|
message.channel.send('This word is already banned');
|
||||||
}
|
}
|
||||||
|
|
|
@ -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}});
|
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')) {
|
if (bannedWords[0].get('word')) {
|
||||||
let censoredMessage = message.content;
|
let censoredMessage = message.content.toLowerCase();
|
||||||
for (let i = 0; i < bannedWords.length; i++) {
|
for (let i = 0; i < bannedWords.length; i++) {
|
||||||
censoredMessage = censoredMessage.replace(bannedWords[i].get('word'), '█'.repeat(bannedWords[i].get('word').length));
|
censoredMessage = censoredMessage.replace(bannedWords[i].get('word'), '█'.repeat(bannedWords[i].get('word').length));
|
||||||
console.log(censoredMessage);
|
console.log(censoredMessage);
|
||||||
|
|
Loading…
Reference in a new issue