{"record":{"id":"ba5303491c7d7888","repo":"jackwener/OpenCLI","slug":"could-not-find-discord-message-input-make-sure-a","errorCode":null,"errorMessage":"Could not find Discord message input. Make sure a channel is open.","messagePattern":"Could not find Discord message input\\. Make sure a channel is open\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"clis/discord-app/send.js","lineNumber":18,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nexport const sendCommand = cli({\n    site: 'discord-app',\n    name: 'send',\n    access: 'write',\n    description: 'Send a message in the active Discord channel',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [{ name: 'text', required: true, positional: true, help: 'Message to send' }],\n    columns: ['Status'],\n    func: async (page, kwargs) => {\n        const text = kwargs.text;\n        await page.evaluate(`\n      (function(text) {\n        // Discord uses a Slate-based editor with [data-slate-editor=\"true\"] or role=\"textbox\"\n        const editor = document.querySelector('[role=\"textbox\"][data-slate-editor=\"true\"], [class*=\"slateTextArea\"]');\n        if (!editor) throw new Error('Could not find Discord message input. Make sure a channel is open.');\n        \n        editor.focus();\n        document.execCommand('insertText', false, text);\n      })(${JSON.stringify(text)})\n    `);\n        await page.wait(0.3);\n        await page.pressKey('Enter');\n        return [{ Status: 'Success' }];\n    },\n});\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/discord-app/send.js#L1-L29","documentation":"The send command injects a script that locates Discord's Slate message editor via '[role=\"textbox\"][data-slate-editor=\"true\"], [class*=\"slateTextArea\"]' and throws Error('Could not find Discord message input. Make sure a channel is open.') when absent. The library throws this because messages can only be typed into an open channel's composer.","triggerScenarios":"Running 'discord-app send --text=...' while the browser sits on the home/DMs screen, no channel is selected, the channel view is still loading when the script runs, the composer is blocked (missing permission to Send Messages, slow-mode cooldown, or a verification notice replaced the editor), or Discord changed the editor's attributes.","commonSituations":"Scripting send without first navigating into a channel; account lacks Send Messages permission in the target channel; slowmode timer preventing the editor from being active; Discord web app update altering data-slate-editor markup.","solutions":["Open/navigate to a specific channel in the browser before running send.","Wait for the channel to finish loading (increase the wait or wait for the editor selector) and retry.","Verify the account has Send Messages permission and is not blocked by slow mode.","Update the editor selector to current Discord markup if the DOM changed."],"exampleFix":"// before\nawait page.evaluate(insertTextScript);\n// after\nawait page.waitForSelector('[role=\"textbox\"][data-slate-editor=\"true\"]');\nawait page.evaluate(insertTextScript);","handlingStrategy":"validation","validationCode":"const hasEditor = await page.evaluate(`Boolean(document.querySelector('[role=\"textbox\"][data-slate-editor=\"true\"], [class*=\"slateTextArea\"]'))`);\nif (!hasEditor) throw new Error('Navigate to a channel before sending');","typeGuard":"function composerReady(state) { return state === true; }","tryCatchPattern":"try {\n  await run('discord-app send --text=\"hello\"');\n} catch (e) {\n  if (/Could not find Discord message input/.test(e.message)) {\n    await navigateToChannel(guildId, channelId);\n    await page.waitForSelector('[role=\"textbox\"][data-slate-editor=\"true\"]');\n    await run('discord-app send --text=\"hello\"');\n  }\n}","preventionTips":["Always open the target channel before sending.","Wait for the Slate editor selector to appear before injecting text.","Check Send Messages permission and slow-mode status for the account.","Re-verify editor selectors after Discord updates its composer markup."],"tags":["discord","dom-selector","message-send","browser-automation"],"backgroundTag":"element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}