{"record":{"id":"23e72ec05e6a11ff","repo":"jackwener/OpenCLI","slug":"discord-app-read","errorCode":null,"errorMessage":"discord-app read","messagePattern":"discord-app read","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/discord-app/read.js","lineNumber":34,"sourceCode":"    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        { name: 'count', required: false, help: 'Number of messages to read (default: 20)', default: '20' },\n        { name: 'guild', required: false, help: 'Guild/server id or visible name for targeted reads' },\n        { name: 'channel', required: false, help: 'Channel id or visible name for targeted reads' },\n        { name: 'url', required: false, help: 'Discord channel URL to open before reading' },\n    ],\n    columns: ['Author', 'Time', 'Message', 'channel_id', 'message_id'],\n    func: async (page, kwargs) => {\n        const count = parsePositiveInt(kwargs.count, 20, 'count');\n        const target = await maybeNavigateToDiscordChannel(page, kwargs, { waitForContent: 'messages' });\n        const messages = assertDiscordMessageRowsBelongToTarget(\n            await readDiscordMessages(page, count),\n            target,\n            'Discord channel read',\n        );\n        if (messages.length === 0) {\n            throw new EmptyResultError('discord-app read', 'No messages were found in the selected Discord channel.');\n        }\n        return messages;\n    },\n});\n\nexport const __test__ = {\n    readCommand,\n};\n","sourceCodeStart":16,"sourceCodeEnd":43,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/read.js#L16-L43","documentation":"The discord-app read command validates that scraped message rows actually belong to the requested target via assertDiscordMessageRowsBelongToTarget, then throws EmptyResultError('discord-app read') if the (validated) message list is empty. This distinguishes a genuinely empty channel from rows that were filtered out as mismatched.","triggerScenarios":"Running 'discord-app read' on a channel with no messages (fresh/new channel, or all messages deleted), or after target-assertion filtering removed rows that didn't belong to the requested channel/author so zero rows remain.","commonSituations":"Reading a just-created channel; count/request scrolled an empty region; account lacks permission to view history so the pane renders empty; targeting the wrong channel by mistake.","solutions":["Verify the channel is the intended one and actually has messages (check in the Discord UI).","Send a test message to the channel, then re-run the read.","Check channel permission (View Message History) for the logged-in account.","Ensure the page has finished loading; retry after a longer wait."],"exampleFix":"// before\nawait run('discord-app read --count=20');\n// after: confirm channel has content first\nawait run('discord-app send --text=\"ping\"');\nconst msgs = await run('discord-app read --count=20');","handlingStrategy":"validation","validationCode":"// confirm the channel has history before reading\nconst bodyText = await page.evaluate('document.body.innerText');\nif (!bodyText.trim()) throw new Error('Channel appears empty or not loaded');","typeGuard":"function hasMessages(rows) { return Array.isArray(rows) && rows.length > 0; }","tryCatchPattern":"try {\n  const msgs = await run('discord-app read --count=20');\n} catch (e) {\n  if (/discord-app read/.test(e.message)) {\n    // channel is genuinely empty or wrong target — verify target, send a test message, retry\n    await verifyChannelTarget();\n  }\n}","preventionTips":["Verify the target channel name/ID before reading.","Wait for message list to render on slow connections.","Check View Message History permission for the account.","Send a sentinel message before reading in automated tests."],"tags":["discord","empty-result","scraping"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}