jackwener/OpenCLI · error · ArgumentError
Could not resolve Discord thread "${threadArg}". Open the pa
Error message
Could not resolve Discord thread "${threadArg}". Open the parent forum/channel first, or pass --guild and --channel ids with --thread. What it means
resolveDiscordThreadTarget throws this ArgumentError when it cannot turn the provided --thread value into a resolvable thread: no current channel context, no parsable thread URL, and no --guild/--channel pair supplied. The library needs either ambient channel context or explicit parent ids to look up the thread.
Source
Thrown at clis/discord-app/utils.js:667
}),
};
}
const current = await getCurrentDiscordRoute(page);
if (current?.guild_id && current?.channel_id) {
return {
guild_id: current.guild_id,
channel_id: current.channel_id,
thread_id: threadArg,
url: buildDiscordChannelUrl({
guildId: current.guild_id,
channelId: current.channel_id,
threadId: threadArg,
}),
};
}
throw new ArgumentError(
`Could not resolve Discord thread "${threadArg}".`,
'Open the parent forum/channel first, or pass --guild and --channel ids with --thread.',
);
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Add --guild <guild_id> --channel <parent_channel_id> alongside --thread
- Open/resolve the parent forum or channel first so current.channel_id is available
- Pass the full thread URL via --url so it can be parsed directly
- Verify the thread id is the numeric snowflake id, not the thread name
Example fix
// before cli thread-read --thread my-thread // after cli thread-read --guild 123456789 --channel 987654321 --thread 112233445566778899
Defensive patterns
Strategy: validation
Validate before calling
if (args.thread && !args.guild && !args.channel && !/^https:\/\/(discord|canary\.discord)\.com\/channels\//.test(args.thread)) throw new Error('Pass --guild and --channel ids with --thread, or a thread --url'); Type guard
function hasThreadContext(a) { return Boolean(a?.url) || Boolean(a?.thread && a.guild && a.channel); } Try / catch
try { await target(args); } catch (e) { if (e instanceof ArgumentError && e.message.includes('Could not resolve Discord thread')) { console.error('Supply parent context: --guild <id> --channel <id> --thread <id>'); process.exitCode = 2; } else throw e; } Prevention
- Resolve/open the parent forum or channel before thread operations
- Store thread ids together with their parent guild/channel ids
- Pass full thread URLs when you only have a link
When it happens
Trigger: Passing --thread <id> without --guild/--channel while no parent forum/channel is currently selected; passing a URL that parseDiscordChannelUrl does not recognize as a thread URL; passing a thread name instead of an id.
Common situations: Running the CLI in a fresh session with no current channel; thread id copied from a webhook or bot context without the parent forum id; renamed/deleted thread whose URL no longer parses as a thread URL.
Related errors
- --url must be a Discord channel URL like https://discord.com
- Pass --url or --guild/--channel to choose a Discord channel.
- Pass --channel with --guild, or use --url.
- --url must be a Discord thread/post URL like https://discord
- Pass --thread <thread_id> or --url <thread_url>.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/a8883e2fce03a8b2.
Report an issue: GitHub.