{"record":{"id":"fcc112428cbb8fe7","repo":"Tyrrrz/DiscordChatExporter","slug":"export-failed","errorCode":null,"errorMessage":"Export failed.","messagePattern":"Export failed\\.","errorType":"exception","errorClass":"CommandException","httpStatus":null,"severity":"error","filePath":"DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs","lineNumber":365,"sourceCode":"            using (console.WithForegroundColor(ConsoleColor.Red))\n            {\n                await console.Error.WriteLineAsync(\"Failed to export the following channel(s):\");\n            }\n\n            foreach (var (channel, message) in errorsByChannel)\n            {\n                await console.Error.WriteAsync($\"{channel.GetHierarchicalName()}: \");\n                using (console.WithForegroundColor(ConsoleColor.Red))\n                    await console.Error.WriteLineAsync(message);\n            }\n\n            await console.Error.WriteLineAsync();\n        }\n\n        // Fail the command only if ALL channels failed to export.\n        // If only some channels failed to export, it's okay.\n        if (errorsByChannel.Count >= unwrappedChannels.Count)\n            throw new CommandException(\"Export failed.\");\n    }\n\n    public override async ValueTask ExecuteAsync(IConsole console)\n    {\n        // Support Ukraine callout\n        if (!IsUkraineSupportMessageDisabled)\n        {\n            console.Output.WriteLine(\n                \"┌────────────────────────────────────────────────────────────────────┐\"\n            );\n            console.Output.WriteLine(\n                \"│   Thank you for supporting Ukraine <3                              │\"\n            );\n            console.Output.WriteLine(\n                \"│                                                                    │\"\n            );\n            console.Output.WriteLine(\n                \"│   As Russia wages a genocidal war against my country,              │\"","sourceCodeStart":347,"sourceCodeEnd":383,"githubUrl":"https://github.com/Tyrrrz/DiscordChatExporter/blob/f6865c82167c3bfee4455da80a1f1ca5e71b95ad/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs#L347-L383","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the per-channel error lines printed immediately above this message — they carry the real cause (401/403/404/empty).","Verify the token still works with a single exportchat on one channel before re-running the batch.","Check network connectivity and Discord status; retry with a lower --parallel value.","Confirm the bot/user has access and the MESSAGE_CONTENT intent is enabled for bot tokens."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Preflight: prove the token works on one channel before the batch\ntry { await exporter.ExportChannelAsync(singleChannelRequest, null, ct); }\ncatch (Exception ex) { Console.Error.WriteLine($\"Preflight failed: {ex.Message}\"); return; }","typeGuard":null,"tryCatchPattern":"try\n{\n    await cli.ExecuteAsync(args);\n}\ncatch (CommandException ex) when (ex.Message == \"Export failed.\")\n{\n    // all channels failed — consult stderr above for per-channel causes\n    logger.LogError(\"All channels failed; see per-channel errors above\");\n}","preventionTips":["Run a single-channel export first to validate token/intent/network.","Capture stderr to correlate per-channel errors with the final failure.","Use --parallel 1 to make rate-limit-related failures visible and ordered."],"tags":["batch","aggregate","export","cli"],"backgroundTag":null,"analyzedSha":"f6865c82167c3bfee4455da80a1f1ca5e71b95ad","analyzedAt":"2026-08-13T18:08:46.403Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}