Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/trustlessmatt/discord-exporter-bot/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The Discord Exporter Bot includes an automatic daily digest task that runs on a schedule without manual intervention. By default, it generates a team digest every day at 12:00 AM Eastern Time.

How It Works

The daily_digest_task is implemented using Discord.py’s @tasks.loop decorator:
@tasks.loop(hours=24)
async def daily_digest_task():
    """Automatically generate daily digest at scheduled time."""
    logger.info("Running scheduled daily digest")

    result = await run_digest_pipeline(bot, config, config.default_hours)

    if result["success"]:
        logger.info("✅ Daily digest completed successfully")
    else:
        logger.error(f"Daily digest failed: {result.get('error', 'Unknown error')}")
See bot.py:659-669.

Default Schedule

scheduled_hour
integer
default:0
Hour of day (0-23) to run the digest in Eastern Time
  • Default: 0 (12:00 AM ET)
  • Timezone: America/New_York (handles DST automatically)
  • Frequency: Every 24 hours
Eastern Time with DSTThe bot uses ZoneInfo("America/New_York") which automatically handles Daylight Saving Time transitions. No manual adjustments needed.

Task Lifecycle

1. Bot Startup

When the bot connects to Discord:
@bot.event
async def on_ready():
    logger.info(f"{bot.user} has connected to Discord!")
    
    if not daily_digest_task.is_running():
        daily_digest_task.start()
        logger.info("Daily digest task started")
See bot.py:594-608.

2. Initial Wait Period

The task calculates how long to wait until the next scheduled time:
@daily_digest_task.before_loop
async def before_daily_digest():
    """Wait until scheduled time to start the loop."""
    await bot.wait_until_ready()

    now = datetime.now(config.eastern_tz)
    target_time = now.replace(hour=config.scheduled_hour, minute=0, second=0, microsecond=0)

    if now.time() >= target_time.time():
        target_time += timedelta(days=1)

    wait_seconds = (target_time - now).total_seconds()
    logger.info(f"⏰ Waiting {wait_seconds/3600:.1f} hours until first digest at {config.scheduled_hour}:00am ET")
    await asyncio.sleep(wait_seconds)
See bot.py:672-685.
Bot starts: 3:00 PM ET
Target time: 12:00 AM ET (next day)
Wait time: 9 hours

Log output:
⏰ Waiting 9.0 hours until first digest at 0:00am ET

3. Recurring Execution

After the first run, the task repeats every 24 hours at the same time.

Customizing the Schedule

You can change the scheduled hour by modifying the Config class in bot.py:
@dataclass
class Config:
    # ... other fields ...
    scheduled_hour: int = 9  # 9am ET
Digest will run at 9:00 AM Eastern Time every day.

What Gets Generated

The scheduled task runs the complete digest pipeline:
  1. Export: Last 24 hours of messages (configurable via config.default_hours)
  2. AI Analysis: Claude processes the transcript
  3. Save: Markdown digest saved to Daily Digests/
  4. Git Push: Automatic commit/push if GitHub is configured
This is identical to running !digest manually.

Logs and Monitoring

Startup Logs

2026-03-04 15:00:00 - INFO - DiscordExporterBot#1234 has connected to Discord!
2026-03-04 15:00:00 - INFO - Connected to: My Team Server
2026-03-04 15:00:00 - INFO - Daily digest task started
2026-03-04 15:00:00 - INFO - ⏰ Waiting 9.0 hours until first digest at 0:00am ET

Execution Logs

2026-03-05 00:00:00 - INFO - Running scheduled daily digest
2026-03-05 00:00:02 - INFO - Starting export for last 24 hours from My Team Server
2026-03-05 00:00:05 - INFO - Exported 45 messages from #engineering
2026-03-05 00:00:06 - INFO - Exported 32 messages from #product
2026-03-05 00:00:07 - INFO - Export complete: 147 messages from 5 channels
2026-03-05 00:00:12 - INFO - Saved digest to Daily Digests/2026-03-04 - Team Digest.md
2026-03-05 00:00:14 - INFO - Successfully pushed Daily Digests/2026-03-04 - Team Digest.md to GitHub
2026-03-05 00:00:14 - INFO - ✅ Daily digest completed successfully

Checking Task Status

You can verify the task is running by checking logs for:
Daily digest task started
⏰ Waiting X hours until first digest at 0:00am ET
If you don’t see these logs, the task may not have started properly.

Task Behavior

Error Handling

  • Export failures: Logged and reported, task continues
  • Claude API errors: Logged and reported, task continues
  • GitHub push failures: Logged but digest still saved locally
  • Task crashes: Bot remains online, task retries at next interval

Restart Behavior

If the bot restarts:
  1. Task recalculates wait time to next scheduled hour
  2. Does not run immediately if schedule was missed
  3. Waits until next scheduled time (e.g., next midnight)
If you want to generate a digest immediately after restart, use the manual !digest command.

Comparison: Manual vs Scheduled

Feature!digest CommandScheduled Task
TriggerManual Discord commandAutomatic on schedule
Time RangeConfigurable (1-720 hours)Fixed (24 hours)
Discord OutputPreview posted in channelNo Discord message
File OutputSame markdown formatSame markdown format
GitHub PushYes (if configured)Yes (if configured)
When to UseOn-demand analysis, custom rangesDaily team summaries

Configuration Reference

Relevant Config fields for scheduled tasks:
@dataclass
class Config:
    scheduled_hour: int = 0              # Hour to run (0-23, ET)
    default_hours: int = 24              # Time range for scheduled digest
    digests_dir: str = "Daily Digests"   # Output directory
    eastern_tz: ZoneInfo = ...           # Timezone (handles DST)
See bot.py:21-39 for full configuration.

Advanced: Custom Task Intervals

The @tasks.loop(hours=24) decorator supports other intervals:
@tasks.loop(hours=12)
async def daily_digest_task():
    # Runs twice per day

Troubleshooting

Task Not Running

  1. Check startup logs for “Daily digest task started”
  2. Verify bot is online with !export command
  3. Check scheduled hour in Config matches your expectation
  4. Review timezone - scheduled_hour is in Eastern Time, not UTC

Digest Not Appearing

  1. Check logs for “Running scheduled daily digest”
  2. Verify ANTHROPIC_API_KEY is set
  3. Check output directory exists and is writable
  4. Review file naming - digests use previous day’s date if run at midnight

GitHub Push Failing

  1. Verify GITHUB_REPO_URL and GITHUB_TOKEN are set
  2. Check repository permissions - token needs push access
  3. Review git logs in bot output for specific errors
  4. Test manual commit to verify credentials work
  • !digest - Generate digest manually on demand
  • !export - Export messages without AI analysis

Build docs developers (and LLMs) love