jackwener/OpenCLI Β· error Β· ArgumentError

emoji required (a single unicode emoji)

Error message

emoji required (a single unicode emoji)

What it means

reaction-add requires a non-empty --emoji argument and throws ArgumentError when it is missing or whitespace-only after trimming. Emoji is used as the reaction key in the POST body, so the command refuses to run without one.

Source

Thrown at clis/slock/reaction-add.js:29

  name: 'reaction-add',
  access: 'write',
  description: 'Add an emoji reaction to a message (POST /messages/:id/reactions). Idempotent server-side.',
  domain: SLOCK_DOMAIN,
  strategy: Strategy.COOKIE,
  browser: true,
  siteSession: 'persistent',
  args: [
    { name: 'messageId', positional: true, required: true, help: 'Full messageId UUID (short ids rejected)' },
    { name: 'emoji', positional: true, required: true, help: 'A single unicode emoji, e.g. πŸ‘' },
    { name: 'server', help: 'Override active server' },
  ],
  columns: ['messageId', 'emoji', 'result'],
  func: async (page, kwargs) => {
    let id;
    try { id = assertMessageIdShape(String(kwargs.messageId ?? '')); }
    catch (e) { throw new ArgumentError(e.message); }
    const emoji = String(kwargs.emoji ?? '').trim();
    if (!emoji) throw new ArgumentError('emoji required (a single unicode emoji)');
    await page.goto(SLOCK_HOME_URL);
    const snippet = buildFetchSnippet({
      method: 'POST',
      path: `/messages/${id}/reactions`,
      body: { emoji },
      serverScoped: true,
      serverIdOverride: kwargs.server,
    });
    const result = await page.evaluate(`(async () => { ${snippet} })()`);
    dispatchEvaluateResult(result);
    return [{ messageId: id, emoji, result: 'added' }];
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Pass a single unicode emoji, e.g. `--emoji πŸ‘`
  2. Quote the emoji in the shell: `--emoji "πŸ‘"`
  3. Check terminal/locale (UTF-8) if the emoji appears to vanish from the argv

Example fix

// before
$ slock reaction-add --messageId <uuid> --emoji=
// after
$ slock reaction-add --messageId <uuid> --emoji "πŸ‘"
Defensive patterns

Strategy: validation

Validate before calling

const emoji = String(kwargs.emoji ?? '').trim();
if (!emoji) throw new Error('--emoji required: pass a single unicode emoji, e.g. --emoji "πŸ‘"');

Type guard

function isEmoji(v) {
  return typeof v === 'string' && v.trim().length > 0 &&
    /\p{Extended_Pictographic}/u.test(v.trim());
}

Try / catch

try {
  await cli('reaction-add', { messageId, emoji });
} catch (e) {
  if (e instanceof ArgumentError && e.message.includes('emoji required')) {
    console.error('Missing --emoji; pass a single unicode emoji quoted for your shell.');
  } else throw e;
}

Prevention

When it happens

Trigger: Invoking `slock reaction-add` without --emoji, with `--emoji ""`, or with a value consisting only of whitespace. The check `String(kwargs.emoji ?? '').trim()` yields an empty string.

Common situations: Forgetting the flag in scripts; shell stripping the emoji (e.g. locale/encoding problems making the argument empty); accidentally passing `--emoji=` with no value; using a plain-text word like `thumbsup` that survives but only matters if it was actually empty β€” the error only fires on truly empty input.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them β€” this error's family across 20 libraries.

Related errors


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