Skip to content
arduinodiscordPublic

About

The new and improved custom discord bot to power the official Arduino discord server @ https://arduino.cc/discord

Resources

Stars

3 stars

Watchers

2 watching

Forks

Latest commit

Β 

History

275 Commits

Folders and files

Repository files navigation

πŸ€– Arduino Discord Bot

The community bot powering the official Arduino Discord

Helpful tags, moderation, automod, logs, modmail and server automation β€” built for the people who keep the server running.

License: GPL-3.0 discord.js Sapphire TypeScript Node


✨ Highlights

🏷️ Slash-command tags Curated troubleshooting guides (/tag) β€” AVRDUDE errors, level shifters, powering boards, and more
πŸ›‘οΈ Image-spam automod Catches the image-cluster spam wave with burst + cross-channel fan-out + perceptual-hash detection, and a one-click moderator console
🚫 Automod text rules The server's old YAGPDB rules: phishing/lookalike links, foreign invites, masked links, duplicates, a website denylist and Discord AutoMod hits β†’ delete + 3h timeout, kick on repeat; plus banned words, mentions, caps, emoji and newline limits
πŸ”¨ Moderation commands /warn (with optional auto-timeout escalation), /warnings, /timeout, /kick, /ban, /purge… every action logged to a mod-action channel
πŸ“œ Logs Message edits/deletes/bulk deletes, member nickname/role/name/timeout changes, join/leave with invite source
🚨 Join-raid detection Alerts on a wave of joins (or of young accounts), with buttons to raise verification or kick the wave; optional minimum account age
πŸ“¬ Modmail Members DM the bot; each conversation becomes a staff ticket thread with replies, notes, snippets, scheduled close and transcripts
🧰 Server automation Auto-crosspost, join/leave + invite-source logging, role-select buttons, message-link quoting
πŸ—£οΈ Staff tooling /say to broadcast rich embeds as the bot
🐳 One-command deploy docker compose up β€” bot + Postgres, migrations applied automatically

πŸš€ Quick start

With Docker (recommended)

git clone https://github.com/arduinodiscord/bot.git
cd bot
cp .env.example .env          # add your BOT_TOKEN (+ any feature channel IDs)
docker compose up -d --build  # builds the bot, starts Postgres, applies migrations

That's it β€” the bot connects, registers its slash commands, and is ready.

Local development

npm install
cp .env.example .env          # set BOT_TOKEN
npm run dev                   # rebuilds on change (tsc -w) and restarts the bot (node --watch)

Privileged intents: enable Message Content and Server Members for your application in the Discord Developer Portal. Invite it with the permission set in SETUP.md (section 1), which includes a ready-made invite URL.


βš™οΈ Configuration

Only BOT_TOKEN is required (plus DATABASE_URL, which Docker wires up, for anything that stores data); every other feature self-disables until it is configured. Non-secret configuration is moving to a live-updatable settings store; for now, .env.example lists the current variables.


πŸ’¬ Commands

All commands are Discord slash commands β€” type / in the server.

Command Description
/tag name:<tag> [user:@user] Post a curated troubleshooting guide, optionally pinging someone
/solved [helper:@user] Mark the current help post solved (and thank a helper); closes the thread
/openposts List open help posts waiting for an answer, oldest first (ephemeral)
/about Bot, Node, and version info
/ping Latency & uptime
/say channel:<#ch> title:… description:… Manage Server β€” send a custom embed (optional fields as Name::Value | Name::Value, and thumbnail)

Plus a "Request more info" right-click (message context-menu) action that posts the needinfo checklist to an asker in one click.

πŸ”¨ Moderation commands (staff; default permission shown, adjustable in Server Settings β†’ Integrations)
Command Default permission Description
/warn user reason Moderate Members Warn a member: records it, DMs them and logs it (auto-timeout at WARN_TIMEOUT_THRESHOLD)
/warnings user Moderate Members Show a user's warnings and moderation history (needs the database)
/delwarn id [reason] Moderate Members Revoke a warning by its ID (shown in /warnings)
/timeout user duration [reason] Moderate Members Time out a member (e.g. 10m, 1h30m; max 28 days)
/untimeout user [reason] Moderate Members Remove a member's timeout
/kick user reason Kick Members Kick a member from the server
/ban user reason [delete_messages] Ban Members Ban a user (works by ID for users not in the server)
/unban user_id [reason] Ban Members Unban a user by their ID
/purge count [user] [reason] Manage Messages Bulk-delete up to 100 recent messages in this channel, optionally from one user
/automod filter add|remove|list Β· /automod status Manage Server Edit the banned-word list, website denylist and invite allowlist; show which rules are on and their thresholds
πŸ“¬ Modmail commands (Moderate Members by default; used inside a ticket thread)
Command Description
/reply message [attachment] Reply to the ticket's user (shows your name)
/areply message [attachment] Reply anonymously, as "Arduino Staff Team"
/note text Add an internal note (not sent to the user)
/snippet send|add|remove|list Send or manage saved replies (tags can be sent too; add/remove need Manage Messages)
/close [delay] [reason] [silent] Close now or after a delay (2h, 1d; cancel stops a scheduled close)
/block user [reason] [duration] Β· /unblock user Stop (or allow again) a user opening tickets
/contact user [message] [anonymous] Open a ticket with a user from the staff side
πŸ“š Available /tag topics

ai Β· ask Β· avrdude Β· codeblock Β· debounce Β· espcomm Β· help Β· hid Β· lab Β· language Β· levelShifter Β· libmissing Β· needinfo Β· ninevolt Β· power Β· pullup Β· reinstall Β· wiki


πŸ›‘οΈ Image-spam automod

A wave of spam β€” both freshly-joined accounts and compromised long-time members β€” posts clusters of images to advertise. This bot targets exactly that pattern without ever disabling image sharing server-wide.

Detection

  • Burst β€” several image messages from one user in a short window (stricter for new members) β†’ alerts mods.
  • Cross-channel fan-out β€” the same image across multiple channels β†’ high confidence (this is what catches compromised veterans, where account age tells you nothing).
  • Known-spam blocklist β€” once a mod confirms an alert, that image is fingerprinted and future copies are caught instantly.

Each image gets a cheap metadata signature (catches identical re-uploads) and a perceptual hash (dHash from a tiny thumbnail β€” catches re-encoded / resized copies via Hamming distance).

Response (tiered): high-confidence hits auto-delete + timeout and then alert; bursts only alert. Every alert lands in the mod-log channel with Confirm / Timeout / Ban / Delete / Not spam buttons β€” a human stays in the loop. Members with Manage Messages (or a configured immune role) are never inspected.

Together with the text rules below, this replaces YAGPDB's AutoMod.


🌊 Text-flooding automod

Some users fragment a single thought across a stream of one-word messages instead of sending it as one message β€” which buries ongoing conversation and leaves no room to reply. The bot flags this pattern: N short messages from one user inside a short window (AUTOMOD_FLOOD_*, defaults: 5 messages ≀ 25 chars in 15 s) lands a Message flooding alert in the same mod-log console as the image automod, with the same Confirm / Timeout / Ban / Delete / Not-spam buttons. By default it only alerts (flooding is usually a habit, not an attack); set AUTOMOD_FLOOD_AUTO_TIMEOUT=true to also time the user out automatically. Members with Manage Messages (or a configured immune role) are never flagged.


πŸ“‘ Cross-channel question-spam automod

New members often fire the same question into every channel at once instead of the one that fits. Two tenure-aware signals catch this (AUTOMOD_CROSSPOST_*):

  • Near-identical fan-out (any tenure) β€” the same question (token-overlap β‰₯ SIMILARITY_PCT, default 80%) across CHANNELS+ channels (default 2) inside the window. High confidence, so the bot auto-deletes the duplicate copies, keeping the first, then alerts.
  • New-member spread (recent joiners only) β€” posting substantive messages in SPREAD_CHANNELS+ channels (default 3) at once, even when reworded enough to dodge the similarity check. Alerts only β€” these aren't strict duplicates.

Both surface in the same mod-log console with the usual action buttons, reuse the existing new-member window, and respect the immune-role/permission checks. Short greetings and reactions (below MIN_CHARS) are ignored.


🚫 Automod text rules

A port of the server's YAGPDB AutoMod setup (src/utils/automod/rules/). Needs MOD_LOG_CHANNEL_ID; staff and immune roles are exempt, and edited messages are checked again.

  • Spam (one composite rule) β€” phishing and Discord/Steam lookalike links (plus an optional downloaded phishing list), invites to other servers, masked links that open a different domain than they show, the same message repeated in one channel, a staff-managed website denylist, an invite in a joining member's name, and messages Discord's own AutoMod flagged. A hit deletes, DMs, times out for 3 hours, records a violation and alerts mods; 3 violations in 48 hours kick.
  • Soft Block β€” single-line # heading messages are deleted silently.
  • Banned words (empty by default), mass mentions, caps, emoji and newlines β€” delete with a short self-deleting notice.

Each rule's actions and thresholds are tunable, and staff edit the banned-word list, website denylist and invite allowlist live with /automod filter (saved to Postgres when connected, in memory otherwise). Alerts carry Time out / Ban / Not a violation buttons.


πŸ”¨ Moderation & logs

  • Moderation commands (see Commands) respect role hierarchy, DM the target where relevant, and post every action to the mod-action log channel (falls back to the automod mod-log). With a database, warnings and actions are kept as moderation history; reaching a configurable number of active warnings can time the member out automatically.
  • Message log β€” edits, deletes and bulk deletes (as a .txt transcript). Old text comes only from the in-memory message cache, which is capped at 24 hours; it is never written to disk.
  • Member log β€” nickname, role, username/display-name and timeout changes.
  • Join-raid detection β€” a burst of joins, or of young accounts, posts one alert per wave to the mod-log with Raise verification level / Restore / Kick listed accounts / Dismiss buttons. An optional minimum account age flags (or kicks) brand-new accounts as they join.

πŸ“¬ Modmail

Members DM the bot to reach staff. After a "Send this to the staff?" confirmation, each conversation becomes a private thread (or forum post) in a staff channel; staff answer with /reply / /areply or the thread buttons, keep internal /notes, and /close (optionally on a delay). Closed tickets are logged with a .txt transcript. Includes blocks, saved snippets, a per-user ticket limit, relayed edits, and retention-based cleanup. Needs Postgres.


🧰 Server management

Ambient helpers, each self-disabling until configured:

  • Auto-crosspost announcement channels, with logging.
  • Join/leave logging with invite-source attribution (+ optional analytics when a DB is present).
  • Role-select buttons to toggle event / server-update opt-in roles.
  • Message-link flattening β€” quote a linked message inline for context.

πŸ™Œ Helper assist

Features aimed at taking repetitive load off the community members who answer the most questions:

  • Keyword β†’ tag suggestions β€” when a message matches a known signature (AVRDUDE, missing-library, ESP upload, level shifters, power, pull-ups, 9V, HID, debounce…), the bot offers the matching tag via a single button, so askers self-serve before a helper repeats a canned answer. Each trigger lives next to its tag in tags.ts. Per-user cooldown; toggle with TAG_SUGGEST_ENABLED. Staff and members holding a recognised role (SUGGEST_IMMUNE_ROLE_IDS: helpers, Trusted, Knowledgeable…) are never shown suggestions.
  • Unformatted-code nudge β€” detects code pasted as plain text and offers the codeblock tag, the single most-repeated ask. Toggle CODE_FORMAT_SUGGEST_ENABLED. Subject to the same role exemption as keyword suggestions.
  • "Just ask" nudge β€” replies to low-effort pings ("can I ask?", "anyone here?") with the ask tag. Conservative patterns; off by default, enable with ASK_SUGGEST_ENABLED=true. Subject to the same role exemption as keyword suggestions.
  • Suggestion ignore list β€” set SUGGEST_IGNORE_CHANNEL_IDS to suppress all three suggestions in specific channels (e.g. staff channels). Listing a forum channel's ID silences all its threads.
  • "Request more info" context-menu β€” right-click any message β†’ Request more info to post the needinfo checklist to the asker in one click. Helpers (REQUEST_INFO_ROLE_IDS) and staff only.
  • Auto-needinfo on thin posts β€” when a new help thread lacks substance (no code, image, URL, or inline code, and the post title + body together are under HELP_NEEDINFO_MIN_CHARS characters), the bot sends a concise checklist and the Mark Solved button in a single message. Off by default (HELP_AUTO_NEEDINFO=true to enable). The full /tag needinfo checklist used by helpers is unaffected.
  • Solve workflow β€” a Mark Solved button on new help threads (set HELP_CHANNEL_IDS) plus /solved [helper:@user], which closes the post and credits whoever helped.
  • Stale-post nudge & auto-archive β€” abandoned help posts get a "still need help?" nudge after a few days, then auto-archive only if no one replies for a while longer (defaults 3 then 7 days β€” helpers often take a while; tune with HELP_STALE_NUDGE_HOURS / HELP_STALE_ARCHIVE_HOURS).
  • /openposts β€” an ephemeral digest of open help posts, oldest-waiting first, so helpers can pick up whatever's been waiting longest.

Help channels can be forum or text channels. List both kinds in HELP_CHANNEL_IDS β€” forum posts and threads opened inside text help channels get the same Mark-Solved / needinfo / stale-sweep / /openposts treatment. The keyword/code/ask suggestions and Request more info work server-wide regardless of channel type (subject to role exemptions and ignore lists). Plain, thread-less messages in a text channel can't be archived, so the thread lifecycle simply doesn't apply to them.

πŸ—οΈ Project structure

src/
β”œβ”€β”€ index.ts                 # client bootstrap (intents, presence, login)
β”œβ”€β”€ commands/                # slash commands (tags, help posts, moderation, /automod, modmail)
β”œβ”€β”€ listeners/               # gateway events (messages, members, invites, logs, automod, modmail DMs…)
β”œβ”€β”€ interaction-handlers/    # buttons & modals (spam/rule consoles, join raid, modmail, role-select, tags)
└── utils/
    β”œβ”€β”€ automod/             # spam detection (image, flood, crosspost, join raid) + rules/ (text rules)
    β”œβ”€β”€ moderation/          # moderation commands: actions, escalation, hierarchy, purge, records
    β”œβ”€β”€ modlog/              # message and member logs
    β”œβ”€β”€ modmail/             # modmail service, DM flow, transcripts, snippets, blocks, hooks
    β”œβ”€β”€ config.ts            # env-driven configuration
    β”œβ”€β”€ db.ts                # optional Prisma (pg driver adapter) with in-memory fallback
    β”œβ”€β”€ tags.ts              # tag content + schema
    └── embed.ts             # shared base embed
prisma/                      # schema + migrations

Stack: discord.js v14 Β· Sapphire framework Β· TypeScript 6 Β· Prisma 7 (+ Postgres, optional).


🀝 Contributing

Want to add a tag or a feature? PRs welcome!

  1. Fork & branch.
  2. Add a tag: edit src/utils/tags.ts and add it to the .addChoices() list in src/commands/tag.ts.
  3. npm run build to type-check.
  4. Open a PR against staging with a clear description.

Found a bug or have an idea? Open an issue.


License: GPL-3.0-or-later · Made with ❀️ by the Arduino Discord community

About

The new and improved custom discord bot to power the official Arduino discord server @ https://arduino.cc/discord

Resources

Stars

3 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages