Tyrrrz/DiscordChatExporter · error · CommandException

Export failed.

Error message

Export failed.

What it means

Thrown as a CommandException at the end of ExportAsync only when EVERY channel in the batch failed to export (errorsByChannel.Count >= unwrappedChannels.Count). Partial failures are tolerated and reported per-channel to stderr; this final throw only occurs when no channel succeeded. The actual per-channel root causes are printed to the console just before this exception.

Source

Thrown at DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:365

            using (console.WithForegroundColor(ConsoleColor.Red))
            {
                await console.Error.WriteLineAsync("Failed to export the following channel(s):");
            }

            foreach (var (channel, message) in errorsByChannel)
            {
                await console.Error.WriteAsync($"{channel.GetHierarchicalName()}: ");
                using (console.WithForegroundColor(ConsoleColor.Red))
                    await console.Error.WriteLineAsync(message);
            }

            await console.Error.WriteLineAsync();
        }

        // Fail the command only if ALL channels failed to export.
        // If only some channels failed to export, it's okay.
        if (errorsByChannel.Count >= unwrappedChannels.Count)
            throw new CommandException("Export failed.");
    }

    public override async ValueTask ExecuteAsync(IConsole console)
    {
        // Support Ukraine callout
        if (!IsUkraineSupportMessageDisabled)
        {
            console.Output.WriteLine(
                "┌────────────────────────────────────────────────────────────────────┐"
            );
            console.Output.WriteLine(
                "│   Thank you for supporting Ukraine <3                              │"
            );
            console.Output.WriteLine(
                "│                                                                    │"
            );
            console.Output.WriteLine(
                "│   As Russia wages a genocidal war against my country,              │"

View on GitHub (pinned to f6865c8216)

Solutions

  1. Read the per-channel error lines printed immediately above this message — they carry the real cause (401/403/404/empty).
  2. Verify the token still works with a single exportchat on one channel before re-running the batch.
  3. Check network connectivity and Discord status; retry with a lower --parallel value.
  4. Confirm the bot/user has access and the MESSAGE_CONTENT intent is enabled for bot tokens.
Defensive patterns

Strategy: try-catch

Validate before calling

// Preflight: prove the token works on one channel before the batch
try { await exporter.ExportChannelAsync(singleChannelRequest, null, ct); }
catch (Exception ex) { Console.Error.WriteLine($"Preflight failed: {ex.Message}"); return; }

Try / catch

try
{
    await cli.ExecuteAsync(args);
}
catch (CommandException ex) when (ex.Message == "Export failed.")
{
    // all channels failed — consult stderr above for per-channel causes
    logger.LogError("All channels failed; see per-channel errors above");
}

Prevention

When it happens

Trigger: A multi-channel export where each channel's try/except in the export loop caught an exception and added it to errorsByChannel, and the count meets or exceeds unwrappedChannels.Count. Most commonly every channel hit the same systemic fault (bad token, no network, missing intent).

Common situations: Expired or revoked token used for a whole-guild export; MESSAGE_CONTENT intent disabled so every channel returns empty/forbidden; corporate firewall blocking discord.com; rate-limited IP with all channels 429-ing; wrong guild ID so every channel 404s.

Related errors


AI-assisted analysis of Tyrrrz/DiscordChatExporter@f6865c8216 (2026-08-13). Data as JSON: /api/errors/fcc112428cbb8fe7. Report an issue: GitHub.