forked from Supositware/Haha-Yes
use regex to remove every instance of the banned words
This commit is contained in:
parent
88c31d9433
commit
4e52a04320
1 changed files with 2 additions and 2 deletions
|
@ -26,9 +26,9 @@ class messageListener extends Listener {
|
||||||
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, '');
|
||||||
|
|
||||||
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));
|
let regex = new RegExp(bannedWords[i].get('word'), 'g');
|
||||||
|
censoredMessage = censoredMessage.replace(regex, '█'.repeat(bannedWords[i].get('word').length));
|
||||||
}
|
}
|
||||||
let Embed = new MessageEmbed()
|
let Embed = new MessageEmbed()
|
||||||
.setColor('#FF0000')
|
.setColor('#FF0000')
|
||||||
|
|
Loading…
Reference in a new issue