forked from Supositware/Haha-Yes
Remove non latin character
This commit is contained in:
parent
4e52a04320
commit
7380224fa4
2 changed files with 6 additions and 1 deletions
|
@ -33,6 +33,7 @@ class BannedWordsCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
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}});
|
const bannedWords = await BannedWords.findOne({where: {word: args.word.toLowerCase(), serverID: message.guild.id}});
|
||||||
|
|
||||||
if (!bannedWords) {
|
if (!bannedWords) {
|
||||||
|
|
|
@ -21,11 +21,15 @@ class messageListener extends Listener {
|
||||||
|
|
||||||
// Banned words
|
// 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')) {
|
if (bannedWords[0].get('word')) {
|
||||||
|
// Remove accent
|
||||||
let censoredMessage = message.content.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
let censoredMessage = message.content.toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
||||||
// Remove zero width space character
|
// Remove zero width space character
|
||||||
censoredMessage = censoredMessage.replace(/\u200B/g, '');
|
censoredMessage = censoredMessage.replace(/\u200B/g, '');
|
||||||
|
// Remove non latin character
|
||||||
|
censoredMessage = censoredMessage.replace(/[\u0250-\ue007]/g, '');
|
||||||
|
|
||||||
for (let i = 0; i < bannedWords.length; i++) {
|
for (let i = 0; i < bannedWords.length; i++) {
|
||||||
let regex = new RegExp(bannedWords[i].get('word'), 'g');
|
let regex = new RegExp(bannedWords[i].get('word'), 'g');
|
||||||
censoredMessage = censoredMessage.replace(regex, '█'.repeat(bannedWords[i].get('word').length));
|
censoredMessage = censoredMessage.replace(regex, '█'.repeat(bannedWords[i].get('word').length));
|
||||||
|
|
Loading…
Reference in a new issue