{"record":{"id":"60efee921996989f","repo":"Tyrrrz/DiscordChatExporter","slug":"option-reuse-media-cannot-be-used-without-medi","errorCode":null,"errorMessage":"Option --reuse-media cannot be used without --media.","messagePattern":"Option --reuse-media cannot be used without --media\\.","errorType":"validation","errorClass":"CommandException","httpStatus":null,"severity":"error","filePath":"DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs","lineNumber":159,"sourceCode":"        EnvironmentVariable = \"FUCK_RUSSIA\",\n        Description = \"Don't print the Support Ukraine message to the console.\",\n        // Use a converter to accept '1' as 'true' to reuse the existing environment variable\n        Converter = typeof(TruthyBooleanInputConverter)\n    )]\n    public bool IsUkraineSupportMessageDisabled { get; set; } = false;\n\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","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/Tyrrrz/DiscordChatExporter/blob/f6865c82167c3bfee4455da80a1f1ca5e71b95ad/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs#L141-L177","documentation":"Thrown by ExportCommandBase.ExportAsync as a CommandException when the user enables asset reuse (--reuse-media) without enabling asset download (--media). Asset reuse is only meaningful when assets are being downloaded to a local directory, so the option combination is rejected up-front before any network work begins. It is a non-fatal CLI usage error surfaced through the CliFx command pipeline.","triggerScenarios":"Invoking any export command (exportchat/exportall/exportguild/exportdm) with the --reuse-media flag set while --media is omitted or false. The check `ShouldReuseAssets && !ShouldDownloadAssets` at ExportCommandBase.cs:157 fires before channels are fetched.","commonSituations":"Copying a flag set from an old run/wiki that used --reuse-media and forgetting to add --media; enabling reuse to skip re-downloading avatars in a CI job but mis-configuring the media flag; shell script that conditionally sets --reuse-media but unconditionally omits --media.","solutions":["Add the --media flag to the same command line (e.g. `--media --reuse-media`).","Remove --reuse-media if you do not want to download assets at all.","If scripting, gate --reuse-media behind the same condition that sets --media so they are always supplied together."],"exampleFix":"// before\ndotnet run -- exportchat -c <id> -t <token> --reuse-media\n// after\ndotnet run -- exportchat -c <id> -t <token> --media --reuse-media","handlingStrategy":"validation","validationCode":"// Validate before invoking the command\nif (options.ReuseMedia && !options.Media)\n    throw new ArgumentException(\"--reuse-media requires --media.\");\n// equivalently, force Media on when ReuseMedia is set\noptions.Media = options.Media || options.ReuseMedia;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat --media and --reuse-media as a paired option group in your wrapper script.","Add a preflight check that asserts any --reuse-media also sets --media.","Document the dependency in your runbook next to the flag definitions."],"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"}