{"record":{"id":"51c0d24f2cb86b57","repo":"jackwener/OpenCLI","slug":"pass-channel-with-guild-or-use-url","errorCode":null,"errorMessage":"Pass --channel with --guild, or use --url.","messagePattern":"Pass --channel with --guild, or use --url\\.","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/discord-app/utils.js","lineNumber":478,"sourceCode":"    const urlArg = stringArg(kwargs.url);\n    if (urlArg) {\n        const parsed = parseDiscordChannelUrl(urlArg);\n        if (!parsed || parsed.thread_id) {\n            throw new ArgumentError('--url must be a Discord channel URL like https://discord.com/channels/<guild_id>/<channel_id>.');\n        }\n        return parsed;\n    }\n\n    const guildArg = stringArg(kwargs.guild);\n    const channelArg = stringArg(kwargs.channel);\n    if (!guildArg && !channelArg) {\n        if (options.required) {\n            throw new ArgumentError('Pass --url or --guild/--channel to choose a Discord channel.');\n        }\n        return null;\n    }\n    if (!channelArg) {\n        throw new ArgumentError('Pass --channel with --guild, or use --url.');\n    }\n\n    let guildId = guildArg;\n    if (guildArg && !isDiscordSnowflake(guildArg) && guildArg !== '@me') {\n        const server = (await listDiscordServers(page)).find((row) => rowMatchesGuild(row, guildArg));\n        if (server?.guild_id) guildId = String(server.guild_id);\n    }\n\n    if (guildId && isDiscordSnowflake(guildId) && isDiscordSnowflake(channelArg)) {\n        return {\n            guild_id: guildId,\n            channel_id: channelArg,\n            url: buildDiscordChannelUrl({ guildId, channelId: channelArg }),\n        };\n    }\n\n    const channels = await listDiscordChannels(page);\n    const match = channels.find((row) => rowMatchesGuild(row, guildId) && rowMatchesChannel(row, channelArg));","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/utils.js#L460-L496","documentation":"resolveDiscordChannelTarget throws this ArgumentError when --guild is provided but --channel is not. The guild alone narrows the server but does not identify a channel, so the resolver refuses the partial selection and points at --url as the alternative.","triggerScenarios":"Calling resolveDiscordChannelTarget with kwargs.guild set (e.g. --guild 'My Server' or a guild id) and kwargs.channel empty/undefined.","commonSituations":"Copy-pasting only part of a flag pair in shell scripts; a quoting bug that drops the --channel value; thinking --guild alone means 'first channel of the server'.","solutions":["Add --channel <channel_id_or_name> alongside --guild.","Or drop --guild/--channel and use a single --url https://discord.com/channels/<guild_id>/<channel_id>.","Quote the channel value in the shell (e.g. --channel \"general\") so it is not swallowed as a flag."],"exampleFix":"// before\nawait resolveDiscordChannelTarget(page, { guild: '123456789' }); // missing channel\n// after\nawait resolveDiscordChannelTarget(page, { guild: '123456789', channel: '987654321' });","handlingStrategy":"validation","validationCode":"if (opts.guild && !opts.channel && !opts.url) throw new Error('--guild requires --channel (or use --url)');","typeGuard":"function hasGuildWithoutChannel(k = {}) { return Boolean(k.guild) && !k.channel && !k.url; }","tryCatchPattern":"try { await runCommand(args); } catch (e) { if (String(e.message).startsWith('Pass --channel with --guild')) { args.push('--channel', resolveChannelId(args.guild)); return runCommand(args); } throw e; }","preventionTips":["Always pass --guild and --channel as a pair, or use --url alone.","Quote values in shell so --channel is not dropped.","Lint CI scripts for orphan --guild flags."],"tags":["discord","cli","missing-argument","argument-validation"],"backgroundTag":"missing-required-argument","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}