I'm coding a Discord js V12 bot, specifically the image
command. Since I simply use the NPM package images-scraper
, you can also look up NSFW images. So, what I am doing now, is adding a profanity filter. This is my code now:
const blacklist = require("./../Other/profanity.js");
blacklist.forEach((word) => {
if (message.content.toLowerCase().includes(word.toLowerCase())) {
message.delete();
message.channel.send("Let's try to keep it family friendly!");
console.log(
`${message.author} used the word ${word} in an image search.`
);
return;
} else {
const image_results = await google.scrape(image_query, 1);
await message.channel.send(image_results[0].url);
};
});
I left some unnecessary code out.
But, if I run this command, it gives me the SyntaxError: await is only valid in async function
error. This await applies to the first await
, before google. So, does anyone know where I can put in a async
function? I already have async execute
somewhere at the top, but it doesn't seem to work. I am sorry if this is a duplicate question, but since it's so specific, I just thougt I'd ask it anyway.