When someone types a banned word the bot automatically deletes the message and sends DM to the user. Add your choice of banned words in the "badWordsList" array.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let badWordsList = [
/** in this parts you can add all the banned words you want, to add more just add: ' word ',**/
' ',
' ',
' ',
];
let regexString =
'\\b' +
badWordsList
.map((badWord) => {
return badWord
.split('')
.map((char) => char.charCodeAt(0))
.join('');
})
.join('\\b|\\b') +
'\\b';
let escapedContent = context.params.event.content
.split(' ')
.map((word) => {
return word
.split('')
.map((char) => char.charCodeAt(0))
.join('');
})
.join(' ');
if (escapedContent.match(new RegExp(regexString, 'i'))) {
await lib.discord.channels['@0.1.1'].messages.destroy({
message_id: `${context.params.event.id}`,
channel_id: `${context.params.event.channel_id}`,
});
await lib.discord.users['@0.1.4'].dms.create({
recipient_id: `${context.params.event.author.id}`,
content: ` `,
embed: {
title: `Banned Word ` /** you can change the embed title here **/,
description: `Hi!, <@${context.params.event.author.id}> You wrote a banned word thats why i deleted your message. ` /** you can change the embed description here **/,
color: 0xed0303 /** you can change the embed color here **/,
},
})};