Skip to content

feat(discord): smart auto-thread mode (true/false/smart)#1054

Open
Hypn0sis wants to merge 9 commits intoRightNow-AI:mainfrom
Hypn0sis:feat/discord-smart-thread
Open

feat(discord): smart auto-thread mode (true/false/smart)#1054
Hypn0sis wants to merge 9 commits intoRightNow-AI:mainfrom
Hypn0sis:feat/discord-smart-thread

Conversation

@Hypn0sis
Copy link
Copy Markdown

Summary

  • Adds auto_thread config field to DiscordConfig with three modes:
    • "true" — always create a thread from each message
    • "false" — never create a thread (default, opt-in)
    • "smart" — create a thread only when the bot is @mentioned
  • Thread name is derived from the message content (strips mention prefix, truncates to Discord's 100-char limit)
  • Auto-thread creation happens after all policy guards (group_policy, mention_only, free_response, rate-limit) so threads are never created for messages the bot would ignore
  • Incoming messages from inside a bot-created thread are detected and routed back into the same thread, preventing duplicate threads
  • MESSAGE_UPDATE events (Discord embed resolution) are deduplicated against already-forwarded MESSAGE_CREATE events to prevent double responses
  • Fixes api_send_thread_message to POST directly to channels/{thread_id}/messages (the correct Discord API endpoint for threads)
  • Adds RevoltAdapter::with_urls_and_channels constructor to support custom URLs + channel restrictions together

Config example

[channels.discord]
bot_token_env = "DISCORD_BOT_TOKEN"
auto_thread = "smart"   # or "true" / "false"

CI note

The Security Audit check may flag rustls-webpki 0.102 — that CVE is addressed in #1041 (already open). If that PR merges first, a rebase of this branch will clear the audit cleanly. The fix: clippy commit in this PR may also overlap with #1041's fixes to copilot.rs; a rebase will resolve any conflict trivially.

Test plan

  • cargo check --workspace --lib passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • cargo test --workspace passes
  • Live: set auto_thread = "smart", @mention bot in server channel → thread created
  • Live: set auto_thread = "smart", message without @mention → no thread created
  • Live: set auto_thread = "false" → no threads ever created
  • Live: replies inside a bot-created thread stay in the thread (no new thread spawned)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants