Checks messages sent in your server for specific bad words, and deletes messages that contain any of those words.
// authenticates you with the API standard library
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let badWordsList = [
'bad',
'evil',
'hate'
];
let regexString = '\\b' + badWordsList.join('\\b|\\b') + '\\b';
if (context.params.event.content.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.channels['@0.1.1'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Please don't use those words in this channel.`
});
}