{"record":{"id":"53859dc52089019c","repo":"jackwener/OpenCLI","slug":"discord-app-search","errorCode":null,"errorMessage":"discord-app search","messagePattern":"discord-app search","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"info","filePath":"clis/discord-app/search.js","lineNumber":63,"sourceCode":"          });\n        });\n        \n        const bodyText = document.body?.innerText || document.body?.textContent || '';\n        const empty = /no results|no messages match|没有结果|无结果/i.test(bodyText);\n        return { items, empty };\n      })()\n    `);\n        if (!searchState || !Array.isArray(searchState.items)) {\n            throw new CommandExecutionError('Discord search returned malformed browser payload.');\n        }\n        const results = searchState.items;\n        // Close search\n        await page.pressKey('Escape');\n        if (results.length === 0) {\n            if (!searchState.empty) {\n                throw new CommandExecutionError('Discord search result selector returned no rows and no explicit empty-state marker.');\n            }\n            throw new EmptyResultError('discord-app search', `No results for \"${query}\".`);\n        }\n        return results;\n    },\n});\n","sourceCodeStart":45,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/search.js#L45-L68","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"// before\nawait run('discord-app search --query=\"meetng tomorow\"');\n// after: broaden the query\nawait run('discord-app search --query=\"meeting\"');","handlingStrategy":"try-catch","validationCode":"// sanity-check the query has a chance before searching\nif (!query || query.trim().length < 2) throw new Error('Query too short/empty');","typeGuard":"function isEmptySearchResult(state) { return Array.isArray(state.items) && state.items.length === 0 && state.empty === true; }","tryCatchPattern":"try {\n  const results = await run(`discord-app search --query=\"${q}\"`);\n} catch (e) {\n  if (/discord-app search/.test(e.message) && /No results for/.test(e.message)) {\n    console.log(`Nothing found for \"${q}\" — try broader terms`);\n  }\n}","preventionTips":["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."],"tags":["discord","search","empty-result"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}