{"record":{"id":"369acfe617b06f82","repo":"jackwener/OpenCLI","slug":"discord-app-channels","errorCode":null,"errorMessage":"discord-app channels","messagePattern":"discord-app channels","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"warning","filePath":"clis/discord-app/channels.js","lineNumber":18,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { EmptyResultError } from '@jackwener/opencli/errors';\nimport { listDiscordChannels } from './utils.js';\n\nexport const channelsCommand = cli({\n    site: 'discord-app',\n    name: 'channels',\n    access: 'read',\n    description: 'List channels in the current Discord server',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [],\n    columns: ['Index', 'Channel', 'Type', 'guild_id', 'channel_id', 'url'],\n    func: async (page) => {\n        const channels = await listDiscordChannels(page);\n        if (channels.length === 0) {\n            throw new EmptyResultError('discord-app channels', 'No Discord channels were found in the current server sidebar.');\n        }\n        return channels;\n    },\n});\n\nexport const __test__ = {\n    channelsCommand,\n};\n","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/channels.js#L1-L27","documentation":"The discord-app channels command enumerates channels from the current server sidebar via listDiscordChannels(page); when it parses zero channels it throws EmptyResultError('discord-app channels') with the hint that no channels were found in the sidebar. The library throws this to distinguish 'navigation worked but nothing matched the sidebar selectors' from a hard failure.","triggerScenarios":"Running 'discord-app channels' when the browser is not on a guild page (home/DMs screen), the guild has no channels visible to the account, the sidebar is collapsed or still loading when the scrape runs, or Discord's DOM changed so the channel selector matches nothing.","commonSituations":"Bot/profile opened discord.com but never navigated into a specific server; slow load causing the scrape to run before the sidebar renders; restricted account that cannot see any channels.","solutions":["Navigate the browser into a server (click a guild) before re-running the command.","Wait for the sidebar to finish loading / increase wait before scraping, then retry.","Check the account can actually see channels in that server (permissions).","Update the channel sidebar selectors if Discord changed its DOM."],"exampleFix":"// before\nclick(guildIcon);\nawait run('discord-app channels');\n// after: ensure a guild view is open and loaded\nclick(guildIcon);\nawait page.wait(1.5);\nawait run('discord-app channels');","handlingStrategy":"validation","validationCode":"// ensure a guild is open and sidebar is populated before running\nawait page.waitForSelector('[class*=\"sidebar\"] [class*=\"channel\"]');","typeGuard":"function hasVisibleChannels(sidebarText) { return sidebarText.trim().length > 0; }","tryCatchPattern":"try {\n  const channels = await run('discord-app channels');\n} catch (e) {\n  if (/discord-app channels/.test(e.message)) {\n    // navigate into a guild and retry once after a wait\n    await navigateToGuild();\n    await page.wait(1.5);\n  }\n}","preventionTips":["Always navigate into a server before listing channels.","Wait for the sidebar to render before scraping.","Confirm account permissions allow viewing channels in the target guild.","Retry with a longer delay on slow connections."],"tags":["discord","empty-result","scraping","browser-automation"],"backgroundTag":"empty-result-set","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}