Reputation: 23
im making a discord bot and am making a swear filter,
const swears = require("./words.json");
const swearWords = [swears];
if (swearWords.some(word => message.content.includes(word))) {
message.reply("BRUH NO NAUGHTEE WURDS");
message.delete().catch(e => {});
}
My Json is a list of swear words,
{
"words": [
"example",
"example2",
"example3"
]}
but when someone swears nothing happens, could someone help me?
Upvotes: 0
Views: 55
Reputation: 536
Here you go:
const swears = require("./words.json");
const swearWords = swears.words;
if (swearWords.some(word => message.content.includes(word))) {
message.reply("BRUH NO NAUGHTEE WURDS");
message.delete().catch(e => {});
}
When you require
a JSON file it's basically as if you copy-paste the JSON code in place of the require(...)
call.
Upvotes: 1