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 > 1View on GitHub (pinned to f6865c8216)
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.
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
- 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.
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
- Option --media-dir cannot be used without --media.
- Attempted to export multiple channels, but the output path i
- Invalid partition limit '{value}'.
- Export failed.
- Provided bot account is missing the MESSAGE_CONTENT privileg
AI-assisted analysis of Tyrrrz/DiscordChatExporter@f6865c8216 (2026-08-13).
Data as JSON: /api/errors/60efee921996989f.
Report an issue: GitHub.