← Public packages
@kentcdodds/x
X API v2 helpers for tweets, search, legacy DMs, and encrypted X Chat via a Fly XDK sidecar.
src/reply-post.ts
39 lines · 1.7 KB · TypeScriptimport { createPost } from './client.ts'
import { parseReplyPostInput } from './create-post-input.ts'
/**
* Create or dry-run an X **reply**; refuses without a parent tweet id.
* Prefer this over create-post when the user asked to reply — it will not
* silently publish a standalone post if the parent id is missing.
*
* Parent id (required): `reply: { in_reply_to_tweet_id }` or aliases
* `replyTo` / `inReplyTo` / `inReplyToTweetId` / `parentId` / `parentTweetId`.
* Unknown input keys are rejected. Publishing still requires confirm: true.
*
* **Exclude reply mentions:** `reply.exclude_reply_user_ids` or top-level
* `excludeReplyUserIds` / `exclude_reply_user_ids` — use when someone asks not
* to be mentioned, or a follow-up should not ping everyone in the chain.
* Dry-run / confirm echo `excludeReplyUserIds` / `exclude_reply_user_ids`.
*
* **Reply mentions:** X auto-prefixes reply-chain @handles. Do **not** start
* reply text with those handles — leading `@name` tokens are stripped before
* send. Dry-run / confirm results include `originalText`, `text`, and
* `strippedHandles`.
*
* @returns Created reply payload, or dry-run request description with
* `mode: 'reply'` and `inReplyToTweetId` / `parentId`.
* @example
* import replyPost from 'kody:@kentcdodds/x/reply-post'
* const draft = await replyPost({
* account: 'kodykoala',
* text: 'Thanks!',
* inReplyToTweetId: '<ackId>',
* excludeReplyUserIds: ['2049113393231978496'],
* dryRun: true,
* })
* // => { dryRun: true, mode: 'reply', excludeReplyUserIds: ['…'], ... }
*/
export default async function replyPostEntrypoint(params: Record<string, unknown> = {}) {
const input = parseReplyPostInput(params)
return await createPost(input)
}