Discord Bot Profanity Filter

Moderate messages in a discord.js bot, using the gaming context so banter survives but real abuse doesn't.

Quick start in Discord Bot

client.on("messageCreate", async (msg) => {
  if (msg.author.bot) return;
  const r = await fetch("https://api.theprofanityapi.com/v1/check", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.PROFANITY_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ text: msg.content, context: "gaming", mode: "balanced" }),
  });
  const { flagged, intent } = await r.json();
  if (flagged) {
    await msg.delete();
    await msg.channel.send(`${msg.author}, that message was removed (${intent}).`);
  }
});

Why context-aware matters

A plain word list flags "this game is sick" or medical text full of anatomical terms. The Profanity API runs a five-layer pipeline that scores intent, so "die" in a gaming taunt and "die" in a real threat are handled differently. Pick a context and the engine adjusts strictness automatically.


Other integrations

Ready to ship moderation?

Get an API key and 300 free requests a month. No credit card required.

Get started free →