Skip to content

feat(discord): keep threads alive by auto-unarchiving on ThreadUpdate - #102

Merged
BK1031 merged 1 commit into
mainfrom
bk1031/thread-keepalive
Aug 8, 2026
Merged

feat(discord): keep threads alive by auto-unarchiving on ThreadUpdate#102
BK1031 merged 1 commit into
mainfrom
bk1031/thread-keepalive

Conversation

@BK1031

@BK1031 BK1031 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
  • Add OnThreadUpdate gateway handler that detects when a thread in the configured guild flips to archived and immediately unarchives it
  • Add service.KeepThreadAlive which unarchives the thread and bumps auto_archive_duration to the 7-day max so re-archive churn is weekly at most
  • Skip locked threads so moderator-closed threads stay closed
  • Unarchive is silent (no message/notification); requires the bot to have MANAGE_THREADS

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

follow up

Comment on lines +15 to +17
_, err := Discord.ChannelEdit(thread.ID, &discordgo.ChannelEdit{
Archived: &archived,
AutoArchiveDuration: 10080,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think we should be fine as i see the option for 7 days

@BK1031
BK1031 merged commit 805be36 into main Aug 8, 2026
19 checks passed
@BK1031
BK1031 deleted the bk1031/thread-keepalive branch August 8, 2026 19:07
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.

1 participant