jackwener/OpenCLI · error · ArgumentError
Could not resolve Discord channel "${channelArg}". Use "open
Error message
Could not resolve Discord channel "${channelArg}". Use "opencli discord-app channels -f json" and retry with --url or numeric --guild/--channel ids. What it means
After arg checks pass, resolveDiscordChannelTarget tries to turn --channel (and a non-snowflake --guild) into numeric ids via listDiscordServers/page lookups and route building. If the channel name/id still cannot be mapped to a concrete channel, it throws this ArgumentError with remediation guidance.
Source
Thrown at clis/discord-app/utils.js:516
return {
guild_id: String(match.guild_id),
channel_id: String(match.channel_id),
url: String(match.url || buildDiscordChannelUrl({ guildId: match.guild_id, channelId: match.channel_id })),
};
}
if (!guildId && isDiscordSnowflake(channelArg)) {
const route = await getCurrentDiscordRoute(page);
if (route?.guild_id) {
return {
guild_id: route.guild_id,
channel_id: channelArg,
url: buildDiscordChannelUrl({ guildId: route.guild_id, channelId: channelArg }),
};
}
}
throw new ArgumentError(
`Could not resolve Discord channel "${channelArg}".`,
'Use "opencli discord-app channels -f json" and retry with --url or numeric --guild/--channel ids.',
);
}
export async function waitForDiscordRoute(page, target, options = {}) {
const timeoutMs = options.timeoutMs ?? 8000;
const intervalSeconds = options.intervalSeconds ?? 0.5;
const started = Date.now();
let lastState = null;
while (Date.now() - started <= timeoutMs) {
lastState = requireObjectEvaluateResult(await page.evaluate(buildRouteStateScript()), 'Discord route state');
const route = lastState?.route;
if (route && String(route.guild_id) === String(target.guild_id) && String(route.channel_id) === String(target.channel_id)) {
if (!target.thread_id || String(route.thread_id || '') === String(target.thread_id)) {
return lastState;
}View on GitHub (pinned to 49907e53dc)
Solutions
- Run "opencli discord-app channels -f json" to list resolvable channels, then retry with the numeric --guild/--channel ids or the exact --url.
- Verify the account is a member of the guild and the channel exists/is visible in the app.
- Use the channel id (snowflake) instead of its display name to skip fuzzy lookup.
- Enable developer mode in Discord and copy the channel link directly.
Example fix
// before
await resolveDiscordChannelTarget(page, { guild: 'My Server', channel: 'genral' }); // typo, unresolvable
// after
await resolveDiscordChannelTarget(page, { guild: '123456789', channel: '987654321' }); // numeric ids Defensive patterns
Strategy: fallback
Validate before calling
const listing = await listChannelsJson(); // "opencli discord-app channels -f json"
const match = listing.find(c => c.name === channelName || c.channel_id === channelArg);
if (!match) throw new Error(`Unknown channel: ${channelArg}`); Type guard
function isSnowflake(v) { return typeof v === 'string' && /^\d{15,21}$/.test(v); } Try / catch
try { const target = await resolveDiscordChannelTarget(page, kwargs, { required: true }); } catch (e) { if (String(e.message).startsWith('Could not resolve Discord channel')) { // retry with numeric ids from `channels -f json`
} else throw e; } Prevention
- Prefer numeric snowflake ids over display names.
- Run "opencli discord-app channels -f json" to confirm the channel is visible to the account.
- Check casing/aliases; ensure the account has joined the guild.
When it happens
Trigger: The channelArg matched no visible channel in the Discord app (wrong name, channel not loaded, guild not joined), or the guild name did not row-match any listed server, so the route could not be built with a numeric channel_id.
Common situations: Passing a channel display name with wrong casing or an alias; the target channel is in a server the bot account cannot see; Discord UI state (server folder collapsed, channel hidden) prevented the lookup; stale channel after server reorganization.
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.
- ${context} target is missing a stable channel/thread id.
- --url must be a Discord thread/post URL like https://discord
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/28f7f196acbbd4c6.
Report an issue: GitHub.