{"record":{"id":"aacbbe95245b0915","repo":"jackwener/OpenCLI","slug":"browser-session-required-for-discord-app-delete","errorCode":null,"errorMessage":"Browser session required for discord-app delete","messagePattern":"Browser session required for discord-app delete","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/discord-app/delete.js","lineNumber":93,"sourceCode":"    name: 'delete',\n    access: 'write',\n    description: 'Delete a message by its ID in the active Discord channel',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [\n        {\n            name: 'message_id',\n            type: 'string',\n            required: true,\n            positional: true,\n            help: 'The ID of the message to delete (visible via Developer Mode or the read command)',\n        },\n    ],\n    columns: ['status', 'message'],\n    func: async (page, kwargs) => {\n        if (!page)\n            throw new CommandExecutionError('Browser session required for discord-app delete');\n        const messageId = kwargs.message_id;\n        if (!/^\\d+$/.test(messageId)) {\n            throw new CommandExecutionError(\n                `Invalid message ID: \"${messageId}\". A Discord message ID is a numeric snowflake (e.g. 1234567890123456789).`\n            );\n        }\n        // Wait a moment for the chat to be fully loaded\n        await page.wait(0.5);\n        const result = await page.evaluate(buildDeleteScript(messageId));\n        if (result.ok) {\n            await page.wait(1);\n        }\n        return [{\n            status: result.ok ? 'success' : 'failed',\n            message: result.message,\n        }];\n    },\n});","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/delete.js#L75-L111","documentation":"The discord-app delete command requires a live browser page because it operates on the DOM of an open Discord client. The command's func checks `if (!page)` and throws CommandExecutionError when no browser session exists, preventing the delete from silently doing nothing.","triggerScenarios":"Running 'discord-app delete --message_id=...' without an active browser session — e.g. the CLI was started without a persistent browser/profile, the session was closed or crashed before the command, or the command is invoked through a path that skips browser initialization.","commonSituations":"Forgot to launch/open the browser session first; browser crashed mid-script; running the delete command in a fresh environment where no profile was opened.","solutions":["Start a browser session (open the discord-app browser/profile) before running delete.","Re-run the full workflow that opens the session and navigates to the channel, then delete.","Check that the browser process didn't crash — restart it and redo the steps.","If scripting, open the page/session programmatically before invoking the delete func."],"exampleFix":"// before\nrun('discord-app delete --message_id=123');\n// after\nopenBrowserSession();\nnavigateToChannel(guildId, channelId);\nrun('discord-app delete --message_id=123');","handlingStrategy":"validation","validationCode":"if (!page || page.isClosed?.()) throw new Error('Open a browser session before deleting messages');","typeGuard":"function hasLivePage(page) { return Boolean(page) && typeof page.evaluate === 'function' && !page.isClosed?.(); }","tryCatchPattern":"try {\n  await run('discord-app delete --message_id=...');\n} catch (e) {\n  if (/Browser session required/.test(e.message)) {\n    await openBrowserSession();\n    await run('discord-app delete --message_id=...');\n  }\n}","preventionTips":["Always open/verify the browser session before DOM commands.","Check page liveness after long waits between commands.","Wrap session bootstrap and commands in one workflow function.","Monitor for browser crashes in long-running scripts."],"tags":["discord","browser-session","precondition"],"backgroundTag":"browser-session-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}