Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions discord/service/thread_keepalive.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package service

import (
"time"

"github.com/bwmarrin/discordgo"
"github.com/gaucho-racing/sentinel/discord/pkg/logger"
)

const threadReopenNotice = "This thread was archived due to inactivity, so I've automatically reopened it. " +
"If this thread is no longer needed, lock it before closing and I'll leave it alone."

// KeepThreadAlive unarchives a thread that Discord just auto-archived and
// bumps its auto-archive window to the maximum (7 days) so the gateway only
// re-archives it weekly instead of on the channel's default window. The
// unarchive is silent — no message is posted and members aren't notified.
// Requires the bot to have MANAGE_THREADS in the guild.
// re-archives it weekly instead of on the channel's default window. A notice
// explaining the reopen and the lock-to-close opt-out is posted in the thread
// and auto-deleted after an hour. Requires the bot to have MANAGE_THREADS in
// the guild.
func KeepThreadAlive(thread *discordgo.Channel) {
archived := false
_, err := Discord.ChannelEdit(thread.ID, &discordgo.ChannelEdit{
Expand All @@ -21,4 +27,5 @@ func KeepThreadAlive(thread *discordgo.Channel) {
return
}
logger.SugarLogger.Infof("thread keepalive: unarchived thread %s (%s)", thread.ID, thread.Name)
SendDisappearingMessage(thread.ID, threadReopenNotice, time.Hour)
}
Loading