jackwener/OpenCLI · error · EmptyResultError

discord-app threads

Error message

discord-app threads

What it means

The 'discord-app threads' command throws EmptyResultError when listDiscordThreads(page, limit) returns no visible forum/thread posts for the selected channel. The library signals this as a failure because a channel targeted as containing threads should render at least one post; an empty result usually means navigation or rendering failed. It protects callers from treating an empty scrape as success.

Source

Thrown at clis/discord-app/threads.js:29

    name: 'threads',
    access: 'read',
    description: 'List visible Discord forum/thread posts in the active or targeted channel',
    domain: 'localhost',
    strategy: Strategy.UI,
    browser: true,
    args: [
        { name: 'limit', required: false, default: '30', help: 'Maximum thread/post cards to return (default: 30)' },
        { name: 'guild', required: false, help: 'Guild/server id or visible name for targeted thread listing' },
        { name: 'channel', required: false, help: 'Forum/channel id or visible name for targeted thread listing' },
        { name: 'url', required: false, help: 'Discord forum/channel URL to open before listing threads' },
    ],
    columns: ['Index', 'Thread', 'Author', 'Updated', 'Preview', 'guild_id', 'channel_id', 'thread_id', 'url'],
    func: async (page, kwargs) => {
        const limit = parsePositiveInt(kwargs.limit, 30, 'limit');
        await maybeNavigateToDiscordChannel(page, kwargs, { waitForContent: 'threads', contentTimeoutMs: 3000 });
        const rows = await listDiscordThreads(page, limit);
        if (rows.length === 0) {
            throw new EmptyResultError('discord-app threads', 'No visible forum/thread posts were found in the selected Discord channel.');
        }
        return rows;
    },
});

export const __test__ = {
    threadsCommand,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Verify the target channel is a forum or contains thread posts, and that posts are visible in the automated browser
  2. Increase the content timeout / wait for the forum grid to render before scraping (maybeNavigateToDiscordChannel waitForContent 'threads' currently waits 3s)
  3. Check the channel isn't empty or fully archived in the Discord client
  4. Update buildListThreadsScript selectors in clis/discord-app/utils.js if the Discord forum UI changed

Example fix

// before
await discordAppThreads(page, { url: channelUrl });
// after
await maybeNavigateToDiscordChannel(page, { url: channelUrl }, { waitForContent: 'threads', contentTimeoutMs: 10000 });
await discordAppThreads(page, { url: channelUrl });
Defensive patterns

Strategy: validation

Validate before calling

function validateThreadsTarget(kwargs) {
  if (kwargs.url && !/discord\.com\/channels\/\d+\/\d+/.test(kwargs.url)) {
    throw new Error('--url must be a Discord channel URL');
  }
}

Type guard

function hasThreads(rows) {
  return Array.isArray(rows) && rows.length > 0;
}

Try / catch

try {
  const rows = await discordAppThreads(page, { url: channelUrl, limit: 30 });
} catch (err) {
  if (String(err.message).includes('discord-app threads')) {
    console.error('No visible threads: check the channel is a forum/has posts and content finished loading.');
  } else throw err;
}

Prevention

When it happens

Trigger: Running `discord-app threads` where the target channel has no visible forum/thread posts, the channel is not a forum/threads channel, navigation waited only 3 seconds for thread content and the grid never rendered, or the threads DOM script matched nothing.

Common situations: Using --url/--guild/--channel pointing at a normal text channel with no forum posts; slow loading in CI exceeding the 3s content timeout; all threads filtered/collapsed in the UI; Discord UI update changing forum-grid selectors.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/8893411b663ef51d. Report an issue: GitHub.