jackwener/OpenCLI · error · EmptyResultError

discord-app servers

Error message

discord-app servers

What it means

The 'discord-app servers' command throws EmptyResultError when the connected Discord client's sidebar yields no guild entries after scraping. The library treats an empty server list as a failed command rather than returning an empty table, because it almost always means the app is not logged in or the sidebar failed to render. It is a deliberate guard so callers never mistake 'nothing found' for 'command succeeded with 0 rows'.

Source

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

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

export const serversCommand = cli({
    site: 'discord-app',
    name: 'servers',
    access: 'read',
    description: 'List all Discord servers (guilds) in the sidebar',
    domain: 'localhost',
    strategy: Strategy.UI,
    browser: true,
    args: [],
    columns: ['Index', 'Server', 'guild_id', 'url'],
    func: async (page) => {
        const servers = await listDiscordServers(page);
        if (servers.length === 0) {
            throw new EmptyResultError('discord-app servers', 'No Discord servers were found in the sidebar.');
        }
        return servers;
    },
});

export const __test__ = {
    serversCommand,
};

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the Discord app/page and confirm you are logged in and the server sidebar is visible before running the command
  2. Re-run the command after waiting for the app to fully load (sidebar rendered)
  3. Log the automation browser into an account that is a member of at least one server
  4. If selectors changed after a Discord UI update, update the list-servers script in clis/discord-app/utils.js to match the new sidebar DOM

Example fix

// before
await discordAppServers(page);
// after
await ensureDiscordLoggedIn(page); // wait for sidebar render/login
const servers = await discordAppServers(page);
Defensive patterns

Strategy: validation

Validate before calling

async function assertServersAvailable(page) {
  const sidebar = await page.$('[class*="guild"]');
  if (!sidebar) throw new Error('Discord sidebar not rendered — log in and wait for the app to load before running servers.');
}

Type guard

function hasServers(v) {
  return Array.isArray(v) && v.length > 0 && v.every(r => r && typeof r === 'object');
}

Try / catch

try {
  const servers = await discordAppServers(page);
} catch (err) {
  if (String(err.message).includes('discord-app servers')) {
    console.error('No servers found: check login state and that the sidebar is visible.');
  } else throw err;
}

Prevention

When it happens

Trigger: Running `discord-app servers` when listDiscordServers(page) returns an empty array: the browser page is not logged into Discord, the guild sidebar is collapsed or not yet rendered, or the in-page list-servers script ran before the Discord app finished loading.

Common situations: Automating Discord in CI where the logged-out login page loads instead of the app; running the command too soon after launching the Discord app so the sidebar hasn't hydrated; an account belonging to zero servers; a Discord UI update changing sidebar DOM 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/2b26bcac4dbf190b. Report an issue: GitHub.