jackwener/OpenCLI · info · EmptyResultError
discord-app search
Error message
discord-app search
What it means
When the search scrape finds zero rows and the page explicitly showed an empty-state marker (searchState.empty), the command throws EmptyResultError('discord-app search', 'No results for "<query>".'). This is the library's 'search worked, nothing matched' signal, distinct from selector/payload failures.
Source
Thrown at clis/discord-app/search.js:63
});
});
const bodyText = document.body?.innerText || document.body?.textContent || '';
const empty = /no results|no messages match|没有结果|无结果/i.test(bodyText);
return { items, empty };
})()
`);
if (!searchState || !Array.isArray(searchState.items)) {
throw new CommandExecutionError('Discord search returned malformed browser payload.');
}
const results = searchState.items;
// Close search
await page.pressKey('Escape');
if (results.length === 0) {
if (!searchState.empty) {
throw new CommandExecutionError('Discord search result selector returned no rows and no explicit empty-state marker.');
}
throw new EmptyResultError('discord-app search', `No results for "${query}".`);
}
return results;
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Broaden or correct the query terms and retry.
- Confirm the message exists and the account can view the channel it's in.
- Remove extra filters (from:, before:, etc.) from the query.
- Target the correct server/channel before searching.
Example fix
// before
await run('discord-app search --query="meetng tomorow"');
// after: broaden the query
await run('discord-app search --query="meeting"'); Defensive patterns
Strategy: try-catch
Validate before calling
// sanity-check the query has a chance before searching
if (!query || query.trim().length < 2) throw new Error('Query too short/empty'); Type guard
function isEmptySearchResult(state) { return Array.isArray(state.items) && state.items.length === 0 && state.empty === true; } Try / catch
try {
const results = await run(`discord-app search --query="${q}"`);
} catch (e) {
if (/discord-app search/.test(e.message) && /No results for/.test(e.message)) {
console.log(`Nothing found for "${q}" — try broader terms`);
}
} Prevention
- Use distinctive query terms and check spelling.
- Remember search scope is the current server/channel and respects permissions.
- Avoid over-specific filters like from:/before: in automated queries.
- Log the failing query to distinguish bad queries from permission gaps.
When it happens
Trigger: Running 'discord-app search --query=...' where the query genuinely has no matches in the current server/channel — misspelled terms, searching the wrong channel scope, or searching for content the account cannot see (permissions filter it out).
Common situations: Typos or over-specific queries; searching a server where the message lives in a channel the account can't read; query with special characters that Discord treats literally; before/after date filters narrowing results to nothing.
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
- No 12306 stations match "${keyword}"
- ${label}
- No papers found for author "${authorText}". Try alternate sp
- No papers found. Try a different keyword.
- crates search
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/53859dc52089019c.
Report an issue: GitHub.