{"record":{"id":"b01bc149df68150a","repo":"jackwener/OpenCLI","slug":"invalid-message-id-messageid-a-discord-mess","errorCode":null,"errorMessage":"Invalid message ID: \"${messageId}\". A Discord message ID is a numeric snowflake (e.g. 1234567890123456789).","messagePattern":"Invalid message ID: \"(.+?)\"\\. A Discord message ID is a numeric snowflake \\(e\\.g\\. 1234567890123456789\\)\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/discord-app/delete.js","lineNumber":96,"sourceCode":"    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});\n\nexport const __test__ = {\n    buildDeleteScript,","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/delete.js#L78-L114","documentation":"Before touching the DOM, the delete command validates that message_id is a numeric snowflake with /^\\d+$/ and throws CommandExecutionError if not. Discord message IDs are 64-bit snowflakes; the library rejects anything else up front to avoid building a doomed delete script.","triggerScenarios":"Passing a non-numeric message_id (e.g. 'abc', '123-456'), a value with whitespace or quotes, a float-formatted number, an empty string, or copying the wrong ID (channel/user snowflakes still pass the regex but wrong ID types fail later; letters/symbols fail here).","commonSituations":"Copying the message link but pasting the channel ID portion instead of the message ID; pasting a URL like 'https://discord.com/channels/.../123' without extracting the last segment; typing the ID by hand with a typo.","solutions":["Pass only the numeric message ID: enable Discord Developer Mode, right-click the message, 'Copy Message ID', and use that digits-only value.","Extract the last numeric segment of a message link: const id = url.split('/').pop();","Trim whitespace and avoid quotes/commas around the value.","If using a variable, coerce/validate with /^\\d+$/.test(id) before calling the command."],"exampleFix":"// before\nrun(`discord-app delete --message_id=\"${url}\"`);\n// after\nconst messageId = url.split('/').pop();\nif (!/^\\d+$/.test(messageId)) throw new Error('Not a snowflake ID');\nrun(`discord-app delete --message_id=${messageId}`);","handlingStrategy":"validation","validationCode":"const messageId = String(kwargs.message_id || '').trim();\nif (!/^\\d+$/.test(messageId)) throw new Error(`Bad snowflake: ${messageId}`);","typeGuard":"function isSnowflakeId(v) { return typeof v === 'string' && /^\\d+$/.test(v.trim()); }","tryCatchPattern":"try {\n  await run(`discord-app delete --message_id=${messageId}`);\n} catch (e) {\n  if (/Invalid message ID/.test(e.message)) {\n    console.error('Use Copy Message ID (Developer Mode) — digits only');\n  }\n}","preventionTips":["Enable Discord Developer Mode and use right-click > Copy Message ID.","If extracting from a link, take the LAST numeric segment.","Never wrap IDs in quotes/commas; keep them as digit strings.","Validate with /^\\d+$/ in your own script before invoking the CLI."],"tags":["discord","validation","input-validation"],"backgroundTag":"invalid-argument-format","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}