{"record":{"id":"a8883e2fce03a8b2","repo":"jackwener/OpenCLI","slug":"could-not-resolve-discord-thread-threadarg-o","errorCode":null,"errorMessage":"Could not resolve Discord thread \"${threadArg}\". Open the parent forum/channel first, or pass --guild and --channel ids with --thread.","messagePattern":"Could not resolve Discord thread \"(.+?)\"\\. Open the parent forum/channel first, or pass --guild and --channel ids with --thread\\.","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/discord-app/utils.js","lineNumber":667,"sourceCode":"            }),\n        };\n    }\n\n    const current = await getCurrentDiscordRoute(page);\n    if (current?.guild_id && current?.channel_id) {\n        return {\n            guild_id: current.guild_id,\n            channel_id: current.channel_id,\n            thread_id: threadArg,\n            url: buildDiscordChannelUrl({\n                guildId: current.guild_id,\n                channelId: current.channel_id,\n                threadId: threadArg,\n            }),\n        };\n    }\n\n    throw new ArgumentError(\n        `Could not resolve Discord thread \"${threadArg}\".`,\n        'Open the parent forum/channel first, or pass --guild and --channel ids with --thread.',\n    );\n}\n","sourceCodeStart":649,"sourceCodeEnd":672,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/utils.js#L649-L672","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncli thread-read --thread my-thread\n// after\ncli thread-read --guild 123456789 --channel 987654321 --thread 112233445566778899","handlingStrategy":"validation","validationCode":"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');","typeGuard":"function hasThreadContext(a) { return Boolean(a?.url) || Boolean(a?.thread && a.guild && a.channel); }","tryCatchPattern":"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; }","preventionTips":["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"],"tags":["cli","argument-validation","discord"],"backgroundTag":"unresolved-target-reference","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}