diff --git a/discord/service/thread_keepalive.go b/discord/service/thread_keepalive.go index 7ddfb59..2d1d2c2 100644 --- a/discord/service/thread_keepalive.go +++ b/discord/service/thread_keepalive.go @@ -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{ @@ -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) }