{"record":{"id":"9876703f5ec1057e","repo":"Tyrrrz/DiscordChatExporter","slug":"option-media-dir-cannot-be-used-without-media","errorCode":null,"errorMessage":"Option --media-dir cannot be used without --media.","messagePattern":"Option --media-dir cannot be used without --media\\.","errorType":"validation","errorClass":"CommandException","httpStatus":null,"severity":"error","filePath":"DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs","lineNumber":165,"sourceCode":"\n    [field: AllowNull, MaybeNull]\n    protected ChannelExporter Exporter => field ??= new ChannelExporter(Discord);\n\n    protected async ValueTask ExportAsync(IConsole console, IReadOnlyList<Channel> channels)\n    {\n        var cancellationToken = console.RegisterCancellationHandler();\n\n        // Asset reuse can only be enabled if the download assets option is set\n        // https://github.com/Tyrrrz/DiscordChatExporter/issues/425\n        if (ShouldReuseAssets && !ShouldDownloadAssets)\n        {\n            throw new CommandException(\"Option --reuse-media cannot be used without --media.\");\n        }\n\n        // Assets directory can only be specified if the download assets option is set\n        if (!string.IsNullOrWhiteSpace(AssetsDirPath) && !ShouldDownloadAssets)\n        {\n            throw new CommandException(\"Option --media-dir cannot be used without --media.\");\n        }\n\n        // Make sure the user does not try to export multiple channels into one file.\n        // Output path must either be a directory or contain template tokens for this to work.\n        // Validate this up-front, before fetching threads, because thread fetching can take a\n        // long time and it's frustrating to fail only after it completes.\n        // https://github.com/Tyrrrz/DiscordChatExporter/issues/799\n        // https://github.com/Tyrrrz/DiscordChatExporter/issues/917\n        // https://github.com/Tyrrrz/DiscordChatExporter/issues/1549\n        var mayExportMultipleChannels =\n            // Multiple channels were provided explicitly\n            channels.Count > 1\n            // Thread inclusion can add more channels to the export\n            || ThreadInclusionMode != ThreadInclusionMode.None;\n\n        var isValidOutputPath =\n            // Anything is valid when exporting a single channel\n            !mayExportMultipleChannels","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/Tyrrrz/DiscordChatExporter/blob/f6865c82167c3bfee4455da80a1f1ca5e71b95ad/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs#L147-L183","documentation":"Thrown by ExportCommandBase.ExportAsync as a CommandException when the user specifies a custom assets directory (--media-dir) without enabling asset download (--media). The assets directory is only used when assets are downloaded, so specifying it alone is rejected up-front. It is a non-fatal CLI usage error.","triggerScenarios":"Running any export subcommand with `--media-dir <path>` while --media is not set. The guard `!string.IsNullOrWhiteSpace(AssetsDirPath) && !ShouldDownloadAssets` at ExportCommandBase.cs:163 fires during ExportAsync validation.","commonSituations":"Pre-configuring an output directory for assets in a script before enabling downloads; copy-pasting a config block that references --media-dir but drops --media; GUI-to-CLI translation where the media checkbox was left off.","solutions":["Add the --media flag alongside --media-dir (e.g. `--media --media-dir ./assets`).","Drop --media-dir if you do not intend to download assets (the default derives the directory from the output path).","In scripts, only emit --media-dir when --media is also emitted."],"exampleFix":"// before\ndotnet run -- exportchat -c <id> -t <token> --media-dir ./assets\n// after\ndotnet run -- exportchat -c <id> -t <token> --media --media-dir ./assets","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrWhiteSpace(options.MediaDir) && !options.Media)\n    throw new ArgumentException(\"--media-dir requires --media.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only emit --media-dir in scripts when --media is also emitted.","Prefer relying on the default asset directory derivation unless you need a custom path."],"tags":["cli","options","configuration","assets"],"backgroundTag":null,"analyzedSha":"f6865c82167c3bfee4455da80a1f1ca5e71b95ad","analyzedAt":"2026-08-13T18:08:46.403Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}