TITLE=Discord Thread Scheduler ROUTE=/services/statusbot LOCALE=en MODIFIED=1792749862 URL=https://wiki.teletypegames.org/services/statusbot L=1 #31 q│ A Free Pascal bot that creates a Discord thread once a week at a fixed time q│ and posts the first message into it. Good for weekly status updates and q│ check-ins. 1Configuration 1═════════════ Environment variables; cenv-example0 is the template. t┌────────────────────┬───────────────────────────┬───────────────────────────┐ t│h Variable t│h Description t│h Example t│ t├────────────────────┼───────────────────────────┼───────────────────────────┤ t│0 cRUN_AT0 t│0 The schedule in cDOW:HH:MM0 t│0 c3:09:000 (Tuesday at t│ t│0 t│0 format (1=Sun, 7=Sat). t│0 09:00) t│ t├────────────────────┼───────────────────────────┼───────────────────────────┤ t│0 cDISCORD_BOT_TOKEN0 t│0 Your Discord Bot's t│0 cMTIzNDU2...0 t│ t│0 t│0 authentication token. t│0 t│ t├────────────────────┼───────────────────────────┼───────────────────────────┤ t│0 cDISCORD_CHANNEL_ID0 t│0 The ID of the channel t│0 c1234567890123456780 t│ t│0 t│0 where the thread will be t│0 t│ t│0 t│0 created. t│0 t│ t├────────────────────┼───────────────────────────┼───────────────────────────┤ t│0 cTHREAD_NAME0 t│0 The base name for the t│0 cWeekly Status0 t│ t│0 t│0 thread. The current date t│0 t│ t│0 t│0 is appended t│0 t│ t│0 t│0 automatically. t│0 t│ t├────────────────────┼───────────────────────────┼───────────────────────────┤ t│0 cTHREAD_MESSAGE0 t│0 The first message to post t│0 c@here Please post0 t│ t│0 t│0 in the thread. Supports t│0 cupdates!0 t│ t│0 t│0 Discord mentions. t│0 t│ t├────────────────────┼───────────────────────────┼───────────────────────────┤ t│0 cARCHIVE_DURATION0 t│0 (Optional) Minutes until t│0 c14400 (1 day) t│ t│0 t│0 the thread is archived. t│0 t│ t│0 t│0 Defaults to 10080 (7 t│0 t│ t│0 t│0 days). t│0 t│ t└────────────────────┴───────────────────────────┴───────────────────────────┘ cRUN_AT0 is cDayOfWeek:Hour:Minute0 — day 1 (Sunday) to 7 (Saturday), hour 0–23, minute 0–59. cRUN_AT=2:14:300 means every Monday at 14:30. 1How it works 1════════════ 1. On startup it parses cRUN_AT0 and validates the environment. 2. It checks the system time every 10 seconds. 3. On a match it calls the Discord API: create the thread named cTHREAD_NAME c(YYYY-MM-DD)0, take the new thread id from the response, then post cTHREAD_MESSAGE0 into it. 4. It waits until the next minute, so the same scheduled minute cannot fire twice. 1Requirements 1════════════ A Discord bot with cSend Messages0 and cCreate Public Threads0 in the target channel. Runs as a standalone binary or in Docker. 1Deploy 1══════ The bot runs in c/srv/stacks/statusbot0 on the server. A push to master that changes cstatusbot.pas0, the cDockerfile0 or ccompose.yaml0 deploys it from Woodpecker (cci-deploy statusbot0, see 1Deployment); the pipeline first compiles it with cfpc0. The c.env0 stays on the server. 1Repository 1══════════ https://git.teletypegames.org/services/statusbot