Make ban word and tag work
This commit is contained in:
parent
e21c3ce145
commit
86e90cd626
1 changed files with 170 additions and 169 deletions
|
@ -18,6 +18,29 @@ class messageListener extends Listener {
|
|||
async exec(message) {
|
||||
if (message.author.bot) return;
|
||||
|
||||
|
||||
// Banned words
|
||||
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));
|
||||
}
|
||||
let Embed = new MessageEmbed()
|
||||
.setColor('#FF0000')
|
||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||
.setDescription(censoredMessage);
|
||||
|
||||
message.channel.send(Embed);
|
||||
return message.delete({reason: `Deleted message: ${message.content}`});
|
||||
} else {
|
||||
// auto responses
|
||||
const autoresponseStat = await autoResponseStat.findOne({where: {serverID: message.guild.id}});
|
||||
if (autoresponseStat) {
|
||||
|
@ -183,30 +206,8 @@ class messageListener extends Listener {
|
|||
} else {
|
||||
return message.channel.send(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Banned words
|
||||
|
||||
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));
|
||||
}
|
||||
let Embed = new MessageEmbed()
|
||||
.setColor('#FF0000')
|
||||
.setAuthor(message.author.username, message.author.displayAvatarURL())
|
||||
.setDescription(censoredMessage);
|
||||
|
||||
message.channel.send(Embed);
|
||||
return message.delete({reason: `Deleted message: ${message.content}`});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue