{"record":{"id":"b38800880d6cf64f","repo":"jackwener/OpenCLI","slug":"discord-app-thread-read","errorCode":null,"errorMessage":"discord-app thread-read","messagePattern":"discord-app thread-read","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/discord-app/thread-read.js","lineNumber":37,"sourceCode":"    args: [\n        { name: 'thread', required: false, help: 'Thread/post id, or a full Discord thread/post URL' },\n        { name: 'count', required: false, default: '20', help: 'Number of messages to read (default: 20)' },\n        { name: 'guild', required: false, help: 'Parent guild/server id or visible name' },\n        { name: 'channel', required: false, help: 'Parent forum/channel id or visible name' },\n        { name: 'url', required: false, help: 'Discord thread/post URL' },\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 resolveDiscordThreadTarget(page, kwargs);\n        await navigateToDiscordTarget(page, target, { waitForContent: 'messages' });\n        const rows = assertDiscordMessageRowsBelongToTarget(\n            await readDiscordMessages(page, count),\n            target,\n            'Discord thread read',\n        );\n        if (rows.length === 0) {\n            throw new EmptyResultError('discord-app thread-read', 'No messages were found in the selected Discord thread.');\n        }\n        return rows;\n    },\n});\n\nexport const __test__ = {\n    threadReadCommand,\n};\n","sourceCodeStart":19,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/thread-read.js#L19-L46","documentation":"The 'discord-app thread-read' command throws EmptyResultError when reading messages from a Discord thread yields zero rows. After target-ownership validation passes, an empty message list is treated as a failed read because threads always have at least the originating message; emptiness means the thread content did not render. This prevents callers from silently getting an empty table on a broken scrape.","triggerScenarios":"Running `discord-app thread-read` against a thread whose messages have not loaded in the browser (readDiscordMessages returned []), e.g. the thread view never finished loading, the thread was deleted/ inaccessible, or the read script executed before messages rendered.","commonSituations":"Pointing the command at an archived or deleted thread; slow network in CI so messages haven't hydrated; passing a thread URL while the app is stuck on a loading screen; Discord UI changes breaking the message DOM selectors.","solutions":["Re-run the command with a longer --timeout so thread messages have time to render","Open the thread URL in the automated browser and confirm messages are actually visible and the thread still exists","Ensure the target channel contains an accessible (non-archived) thread","If Discord changed its message DOM, update buildReadMessageScript/readDiscordMessages selectors in clis/discord-app/utils.js"],"exampleFix":"// before\nawait discordAppThreadRead(page, { url: threadUrl });\n// after\nawait waitForDiscordContent(page, 'messages', { timeoutMs: 15000 });\nawait discordAppThreadRead(page, { url: threadUrl });","handlingStrategy":"validation","validationCode":"function validateThreadTarget(url) {\n  const m = url.match(/discord\\.com\\/channels\\/(\\d+)\\/(\\d+)\\/(\\d+)/(?:\\?.*)?$/);\n  if (!m) throw new Error('Provide a full thread URL: /channels/<guild>/<channel>/<thread>');\n}","typeGuard":"function hasMessages(rows) {\n  return Array.isArray(rows) && rows.length > 0;\n}","tryCatchPattern":"try {\n  const rows = await discordAppThreadRead(page, { url: threadUrl, count: 20 });\n} catch (err) {\n  if (String(err.message).includes('thread-read')) {\n    console.error('Thread had no readable messages: confirm it exists, is not archived, and messages have rendered.');\n  } else throw err;\n}","preventionTips":["Confirm the thread exists and is not archived/deleted before reading","Wait for message content to render before invoking thread-read","Increase the command timeout on slow networks/CI","Use fresh, complete thread URLs copied from the Discord client"],"tags":["discord","empty-result","thread"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}