Tyrrrz/DiscordChatExporter · error · CommandException

Option --reuse-media cannot be used without --media.

Error message

Option --reuse-media cannot be used without --media.

What it means

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.

Source

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

        EnvironmentVariable = "FUCK_RUSSIA",
        Description = "Don't print the Support Ukraine message to the console.",
        // Use a converter to accept '1' as 'true' to reuse the existing environment variable
        Converter = typeof(TruthyBooleanInputConverter)
    )]
    public bool IsUkraineSupportMessageDisabled { get; set; } = false;

    [field: AllowNull, MaybeNull]
    protected ChannelExporter Exporter => field ??= new ChannelExporter(Discord);

    protected async ValueTask ExportAsync(IConsole console, IReadOnlyList<Channel> channels)
    {
        var cancellationToken = console.RegisterCancellationHandler();

        // Asset reuse can only be enabled if the download assets option is set
        // https://github.com/Tyrrrz/DiscordChatExporter/issues/425
        if (ShouldReuseAssets && !ShouldDownloadAssets)
        {
            throw new CommandException("Option --reuse-media cannot be used without --media.");
        }

        // Assets directory can only be specified if the download assets option is set
        if (!string.IsNullOrWhiteSpace(AssetsDirPath) && !ShouldDownloadAssets)
        {
            throw new CommandException("Option --media-dir cannot be used without --media.");
        }

        // Make sure the user does not try to export multiple channels into one file.
        // Output path must either be a directory or contain template tokens for this to work.
        // Validate this up-front, before fetching threads, because thread fetching can take a
        // long time and it's frustrating to fail only after it completes.
        // https://github.com/Tyrrrz/DiscordChatExporter/issues/799
        // https://github.com/Tyrrrz/DiscordChatExporter/issues/917
        // https://github.com/Tyrrrz/DiscordChatExporter/issues/1549
        var mayExportMultipleChannels =
            // Multiple channels were provided explicitly
            channels.Count > 1

View on GitHub (pinned to f6865c8216)

Solutions

  1. Add the --media flag to the same command line (e.g. `--media --reuse-media`).
  2. Remove --reuse-media if you do not want to download assets at all.
  3. If scripting, gate --reuse-media behind the same condition that sets --media so they are always supplied together.

Example fix

// before
dotnet run -- exportchat -c <id> -t <token> --reuse-media
// after
dotnet run -- exportchat -c <id> -t <token> --media --reuse-media
Defensive patterns

Strategy: validation

Validate before calling

// Validate before invoking the command
if (options.ReuseMedia && !options.Media)
    throw new ArgumentException("--reuse-media requires --media.");
// equivalently, force Media on when ReuseMedia is set
options.Media = options.Media || options.ReuseMedia;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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