Skip to main content

Affiliate Cleanup

Delete messages that contain affiliate or tracking links, alert moderators, and ask the author to post a clean link.

Why Use This Feature?

  1. Removes referral and tracking links in every channel, so members can't earn commissions from your community.
  2. Names every matched platform in one alert, so moderators see what was removed.
  3. Tells the author privately how to repost, so a useful link can come back without the tracking.

How It Works

  • What it reads — New messages and edits that change a message's text, from members other than bots, that a regex rule hasn't already deleted. The bot sees edits only for messages it has seen since its last reconnect, up to the 200 most recent in each channel.
  • How it matches — Every platform pattern runs against the message text as written, and the bot collects every platform that matches.
  • What it does — When at least one platform matches, the bot posts the alert, sends the direct message, and then makes one attempt to delete the message.

The alert is an embed titled "Affiliate content removed" that shows the author, the channel ID, the matched platforms, an excerpt of up to 700 characters, and a link to the message. It posts before the delete, so it appears even when the delete fails.

warning

The panel labels the channel setting Monitored channel, but the feature checks every channel. That setting is only the alert channel, and leaving it out skips the alert.

Requirements

Settings

FieldDescription
Link patterns (platforms)1 to 100 platforms, each with a Platform name of up to 100 characters and a Regular expression.
Monitored channel (channel)Optional alert channel for removal alerts.
Member notice → Text (direct-message-payload.content)Optional direct message of up to 2,000 characters, sent as written without filling in message variables.
Exempt roles (excluded-roles)Optional list of 1 to 100 roles whose members the feature skips.

Example

Affiliate cleanup settings
json
{
  "platforms": [
    { "platform": "Amazon", "regex": { "pattern": "[?&]tag=", "flags": "i" } }
  ],
  "channel": { "channel-id": "123456789012345678" },
  "direct-message-payload": { "content": "Please repost the link without the affiliate tag." }
}

Limits

  • Platforms — Up to 100.
  • Excerpt — Up to 700 characters of the message.

Troubleshooting

  • The alert says "removed" but the message is still there — The bot lacks Manage Messages in that channel.
  • A member got two direct messages — A regex rule matched but couldn't delete the message, so affiliate cleanup ran too.
  • Moderators' links are removed — Administrators aren't skipped automatically, so add their roles to Exempt roles.

Changes from the legacy bot

The legacy bot skipped anyone with the Administrator permission, and it sent the alert, the direct message, and the delete at the same time. The rewrite skips only excluded roles and runs those steps in order.