jackwener/OpenCLI · warning · EmptyResultError

discord-app channels

Error message

discord-app channels

What it means

The discord-app channels command enumerates channels from the current server sidebar via listDiscordChannels(page); when it parses zero channels it throws EmptyResultError('discord-app channels') with the hint that no channels were found in the sidebar. The library throws this to distinguish 'navigation worked but nothing matched the sidebar selectors' from a hard failure.

Source

Thrown at clis/discord-app/channels.js:18

import { cli, Strategy } from '@jackwener/opencli/registry';
import { EmptyResultError } from '@jackwener/opencli/errors';
import { listDiscordChannels } from './utils.js';

export const channelsCommand = cli({
    site: 'discord-app',
    name: 'channels',
    access: 'read',
    description: 'List channels in the current Discord server',
    domain: 'localhost',
    strategy: Strategy.UI,
    browser: true,
    args: [],
    columns: ['Index', 'Channel', 'Type', 'guild_id', 'channel_id', 'url'],
    func: async (page) => {
        const channels = await listDiscordChannels(page);
        if (channels.length === 0) {
            throw new EmptyResultError('discord-app channels', 'No Discord channels were found in the current server sidebar.');
        }
        return channels;
    },
});

export const __test__ = {
    channelsCommand,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Navigate the browser into a server (click a guild) before re-running the command.
  2. Wait for the sidebar to finish loading / increase wait before scraping, then retry.
  3. Check the account can actually see channels in that server (permissions).
  4. Update the channel sidebar selectors if Discord changed its DOM.

Example fix

// before
click(guildIcon);
await run('discord-app channels');
// after: ensure a guild view is open and loaded
click(guildIcon);
await page.wait(1.5);
await run('discord-app channels');
Defensive patterns

Strategy: validation

Validate before calling

// ensure a guild is open and sidebar is populated before running
await page.waitForSelector('[class*="sidebar"] [class*="channel"]');

Type guard

function hasVisibleChannels(sidebarText) { return sidebarText.trim().length > 0; }

Try / catch

try {
  const channels = await run('discord-app channels');
} catch (e) {
  if (/discord-app channels/.test(e.message)) {
    // navigate into a guild and retry once after a wait
    await navigateToGuild();
    await page.wait(1.5);
  }
}

Prevention

When it happens

Trigger: Running 'discord-app channels' when the browser is not on a guild page (home/DMs screen), the guild has no channels visible to the account, the sidebar is collapsed or still loading when the scrape runs, or Discord's DOM changed so the channel selector matches nothing.

Common situations: Bot/profile opened discord.com but never navigated into a specific server; slow load causing the scrape to run before the sidebar renders; restricted account that cannot see any channels.

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/369acfe617b06f82. Report an issue: GitHub.