jackwener/OpenCLI · error · ArgumentError
Pass --thread <thread_id> or --url <thread_url>.
Error message
Pass --thread <thread_id> or --url <thread_url>.
What it means
resolveDiscordThreadTarget resolves a Discord thread target from CLI args. This ArgumentError is thrown when neither --thread nor --url was provided, so there is no way to identify the thread. It is a usage error, not a runtime failure.
Source
Thrown at clis/discord-app/utils.js:631
);
}
}
return rows;
}
export async function resolveDiscordThreadTarget(page, kwargs = {}) {
const urlArg = stringArg(kwargs.url);
if (urlArg) {
const parsed = parseDiscordChannelUrl(urlArg);
if (!parsed || !parsed.thread_id) {
throw new ArgumentError('--url must be a Discord thread/post URL like https://discord.com/channels/<guild_id>/<channel_id>/<thread_id>.');
}
return parsed;
}
const threadArg = stringArg(kwargs.thread);
if (!threadArg) {
throw new ArgumentError('Pass --thread <thread_id> or --url <thread_url>.');
}
const parsedThreadUrl = parseDiscordChannelUrl(threadArg);
if (parsedThreadUrl?.thread_id) return parsedThreadUrl;
const channelTarget = hasDiscordChannelTarget(kwargs)
? await resolveDiscordChannelTarget(page, kwargs, { required: true })
: null;
if (channelTarget) {
return {
guild_id: channelTarget.guild_id,
channel_id: channelTarget.channel_id,
thread_id: threadArg,
url: buildDiscordChannelUrl({
guildId: channelTarget.guild_id,
channelId: channelTarget.channel_id,
threadId: threadArg,
}),View on GitHub (pinned to 49907e53dc)
Solutions
- Pass --thread <thread_id> with the thread's id
- Pass --url <thread_url> with the Discord message/thread URL instead
- Ensure the --thread value is non-empty (check the shell variable is set)
- If you only have a channel, open the parent forum/channel context first so the current channel can imply the thread
Example fix
// before cli thread-read --guild 123 --channel 456 // after cli thread-read --thread 987654321098765432
Defensive patterns
Strategy: validation
Validate before calling
if (!process.env.THREAD_ID && !args.url) throw new Error('Provide --thread <id> or --url <thread_url>'); Type guard
function hasThreadTarget(a) { return typeof a === 'object' && a !== null && (typeof a.thread === 'string' && a.thread.trim() !== '' || typeof a.url === 'string' && a.url.trim() !== ''); } Try / catch
try { await target(args); } catch (e) { if (e instanceof ArgumentError && /--thread/.test(e.message)) { console.error('Usage: pass --thread <id> or --url <url>'); process.exitCode = 2; } else throw e; } Prevention
- Always pass --thread or --url for thread commands
- Validate CLI args in wrapper scripts before invoking
- Use shell : "${VAR:?}" guards for variables feeding flags
When it happens
Trigger: Calling a discord-app command that needs a thread (e.g. reading/posting in a thread) without passing --thread <thread_id> or --url <thread_url>; passing --thread as an empty string or whitespace-only value so stringArg(kwargs.thread) yields ''.
Common situations: Developers copy examples that only set --guild/--channel and forget the thread id; scripting the CLI where the thread id variable is unset; confusing channel id with thread id and omitting --thread entirely.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
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
- Could not resolve Discord thread "${threadArg}". Open the pa
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/25247f5ae323bb0c.
Report an issue: GitHub.