jackwener/OpenCLI · error · CommandExecutionError
Browser session required for discord-app delete
Error message
Browser session required for discord-app delete
What it means
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.
Source
Thrown at clis/discord-app/delete.js:93
name: 'delete',
access: 'write',
description: 'Delete a message by its ID in the active Discord channel',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [
{
name: 'message_id',
type: 'string',
required: true,
positional: true,
help: 'The ID of the message to delete (visible via Developer Mode or the read command)',
},
],
columns: ['status', 'message'],
func: async (page, kwargs) => {
if (!page)
throw new CommandExecutionError('Browser session required for discord-app delete');
const messageId = kwargs.message_id;
if (!/^\d+$/.test(messageId)) {
throw new CommandExecutionError(
`Invalid message ID: "${messageId}". A Discord message ID is a numeric snowflake (e.g. 1234567890123456789).`
);
}
// Wait a moment for the chat to be fully loaded
await page.wait(0.5);
const result = await page.evaluate(buildDeleteScript(messageId));
if (result.ok) {
await page.wait(1);
}
return [{
status: result.ok ? 'success' : 'failed',
message: result.message,
}];
},
});View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before
run('discord-app delete --message_id=123');
// after
openBrowserSession();
navigateToChannel(guildId, channelId);
run('discord-app delete --message_id=123'); Defensive patterns
Strategy: validation
Validate before calling
if (!page || page.isClosed?.()) throw new Error('Open a browser session before deleting messages'); Type guard
function hasLivePage(page) { return Boolean(page) && typeof page.evaluate === 'function' && !page.isClosed?.(); } Try / catch
try {
await run('discord-app delete --message_id=...');
} catch (e) {
if (/Browser session required/.test(e.message)) {
await openBrowserSession();
await run('discord-app delete --message_id=...');
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Browser session required for bilibili subtitle
- Browser page required
- Browser session required for instagram reel
- Browser session required for linkedin services-read
- Browser session required for linkedin thread-snapshot
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/aacbbe95245b0915.
Report an issue: GitHub.