feat(discord): keep threads alive by auto-unarchiving on ThreadUpdate - #102
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0c79b68b5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| service.Discord.AddHandler(OnGuildMemberUpdate) | ||
| service.Discord.AddHandler(OnGuildMemberRemove) | ||
| service.Discord.AddHandler(OnUserUpdate) | ||
| service.Discord.AddHandler(OnThreadUpdate) |
There was a problem hiding this comment.
Reconcile threads after missed gateway events
When this deploy starts with an already archived thread, or the bot is disconnected when a thread auto-archives, no ThreadUpdate is delivered or replayed and this handler is the only path that invokes KeepThreadAlive. The affected thread therefore remains archived permanently; add a startup/Ready sweep and periodic reconciliation of archived, unlocked threads so missed events recover.
Useful? React with 👍 / 👎.
| _, err := Discord.ChannelEdit(thread.ID, &discordgo.ChannelEdit{ | ||
| Archived: &archived, | ||
| AutoArchiveDuration: 10080, |
There was a problem hiding this comment.
Avoid coupling unarchive to a gated archive duration
In guilds without Discord's SEVEN_DAY_THREAD_ARCHIVE feature, 10080 is not an allowed auto-archive duration, so Discord rejects this entire PATCH—including Archived: false—and the thread remains archived. Select a duration supported by the configured guild or retry the unarchive without the gated duration.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
think we should be fine as i see the option for 7 days
OnThreadUpdategateway handler that detects when a thread in the configured guild flips to archived and immediately unarchives itservice.KeepThreadAlivewhich unarchives the thread and bumpsauto_archive_durationto the 7-day max so re-archive churn is weekly at most