jackwener/OpenCLI · error

Could not find Discord message input. Make sure a channel is

Error message

Could not find Discord message input. Make sure a channel is open.

What it means

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.

Source

Thrown at clis/discord-app/send.js:18

import { cli, Strategy } from '@jackwener/opencli/registry';
export const sendCommand = cli({
    site: 'discord-app',
    name: 'send',
    access: 'write',
    description: 'Send a message in the active Discord channel',
    domain: 'localhost',
    strategy: Strategy.UI,
    browser: true,
    args: [{ name: 'text', required: true, positional: true, help: 'Message to send' }],
    columns: ['Status'],
    func: async (page, kwargs) => {
        const text = kwargs.text;
        await page.evaluate(`
      (function(text) {
        // Discord uses a Slate-based editor with [data-slate-editor="true"] or role="textbox"
        const editor = document.querySelector('[role="textbox"][data-slate-editor="true"], [class*="slateTextArea"]');
        if (!editor) throw new Error('Could not find Discord message input. Make sure a channel is open.');
        
        editor.focus();
        document.execCommand('insertText', false, text);
      })(${JSON.stringify(text)})
    `);
        await page.wait(0.3);
        await page.pressKey('Enter');
        return [{ Status: 'Success' }];
    },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open/navigate to a specific channel in the browser before running send.
  2. Wait for the channel to finish loading (increase the wait or wait for the editor selector) and retry.
  3. Verify the account has Send Messages permission and is not blocked by slow mode.
  4. Update the editor selector to current Discord markup if the DOM changed.

Example fix

// before
await page.evaluate(insertTextScript);
// after
await page.waitForSelector('[role="textbox"][data-slate-editor="true"]');
await page.evaluate(insertTextScript);
Defensive patterns

Strategy: validation

Validate before calling

const hasEditor = await page.evaluate(`Boolean(document.querySelector('[role="textbox"][data-slate-editor="true"], [class*="slateTextArea"]'))`);
if (!hasEditor) throw new Error('Navigate to a channel before sending');

Type guard

function composerReady(state) { return state === true; }

Try / catch

try {
  await run('discord-app send --text="hello"');
} catch (e) {
  if (/Could not find Discord message input/.test(e.message)) {
    await navigateToChannel(guildId, channelId);
    await page.waitForSelector('[role="textbox"][data-slate-editor="true"]');
    await run('discord-app send --text="hello"');
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/ba5303491c7d7888. Report an issue: GitHub.