diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-13 01:24:10 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-13 01:24:10 +0200 |
| commit | 710f616c05983f4b92944e05ad9dd485e1cdb121 (patch) | |
| tree | 892b209032575246abc5e2a66eed856c95b28c3c /README.md | |
| download | timeoutinator-710f616c05983f4b92944e05ad9dd485e1cdb121.tar.gz timeoutinator-710f616c05983f4b92944e05ad9dd485e1cdb121.zip | |
init
Diffstat (limited to '')
| -rw-r--r-- | README.md | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..7a8d638 --- /dev/null +++ b/README.md | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | # Timeoutinator | ||
| 2 | |||
| 3 | A Discord bot that instantly **timeouts** anyone who posts in a configured channel and **purges** all of their messages from the last 24 hours. | ||
| 4 | |||
| 5 | ## How it works | ||
| 6 | |||
| 7 | 1. User sends a message in the policed channel. | ||
| 8 | 2. Bot immediately times them out (`Moderate Members` — configurable duration, default 1 hour). | ||
| 9 | 3. Bot bulk-deletes every message that user posted **in any channel of the guild** over the past 24 hours (including the triggering message). | ||
| 10 | |||
| 11 | Bots, system messages, and webhook messages are ignored. The bot's own messages are also ignored. Concurrent handling of the same user is deduplicated so rapid-fire spam doesn't cause duplicate timeouts or purge races. | ||
| 12 | |||
| 13 | ## Setup | ||
| 14 | |||
| 15 | ### 1. Create a Discord Application | ||
| 16 | |||
| 17 | 1. Go to [discord.com/developers/applications](https://discord.com/developers/applications) | ||
| 18 | 2. Click **New Application** → name it → **Bot** tab → **Add Bot** | ||
| 19 | 3. Under the bot, click **Reset Token** and copy the token — this is your `DISCORD_TOKEN` | ||
| 20 | |||
| 21 | ### 2. Enable Required Intents | ||
| 22 | |||
| 23 | In the **Bot** tab, scroll to **Privileged Gateway Intents**. | ||
| 24 | The bot only needs **Message Content** if you want to read message content — by default, only `GUILD_MESSAGES` is required, which is non-privileged. No privileged intents are required. | ||
| 25 | |||
| 26 | ### 3. Invite the Bot | ||
| 27 | |||
| 28 | Use this URL (replace `YOUR_BOT_CLIENT_ID` with the bot's Client ID from the **General Information** tab): | ||
| 29 | |||
| 30 | ``` | ||
| 31 | https://discord.com/api/oauth2/authorize?client_id=YOUR_BOT_CLIENT_ID&permissions=1099511702528&scope=bot | ||
| 32 | ``` | ||
| 33 | |||
| 34 | Required permissions (encoded in the URL): | ||
| 35 | |||
| 36 | | Permission | Why | | ||
| 37 | |-------------------------|------------------------------------------| | ||
| 38 | | View Channels | See the policed channel and the channels to purge | | ||
| 39 | | Read Message History | Fetch messages to purge | | ||
| 40 | | Manage Messages | Delete messages via bulk-delete endpoint | | ||
| 41 | | Moderate Members | Apply timeouts | | ||
| 42 | |||
| 43 | ### 4. Run | ||
| 44 | |||
| 45 | ```bash | ||
| 46 | cp .env.example .env # or export the env vars directly | ||
| 47 | # edit .env with your token and target channel ID | ||
| 48 | |||
| 49 | cargo run --release | ||
| 50 | ``` | ||
| 51 | |||
| 52 | ## Environment Variables | ||
| 53 | |||
| 54 | | Variable | Required | Default | Description | | ||
| 55 | |-----------------------|----------|---------|----------------------------------------------------------------| | ||
| 56 | | `DISCORD_TOKEN` | ✅ | — | Bot token from the Discord Developer Portal | | ||
| 57 | | `TARGET_CHANNEL_ID` | ✅ | — | Snowflake ID of the channel to police (right-click → Copy ID) | | ||
| 58 | | `TIMEOUT_MINUTES` | ❌ | `60` | Timeout duration in minutes (1–40320, i.e. up to 28 days) | | ||
| 59 | | `PURGE_HOURS` | ❌ | `24` | How far back (hours) to look when deleting messages | | ||
| 60 | |||
| 61 | ## Requirements | ||
| 62 | |||
| 63 | - Rust 1.85+ (edition 2024) | ||
| 64 | - Network access (to fetch crates and connect to Discord's gateway) | ||
