import type { RichTextBuilder } from '@devvit/shared-types/richtext/RichTextBuilder.js'; import { T1, T2, T3, T5 } from '@devvit/shared-types/tid.js'; import { type FilterOptions } from '../helpers/filterThing.js'; import type { CommonFlair } from './Flair.js'; import { Listing } from './Listing.js'; import { type AddRemovalNoteOptions } from './ModNote.js'; import type { ModeratorReport } from './Post.js'; import { User } from './User.js'; export type CommentSort = 'confidence' | 'top' | 'new' | 'controversial' | 'old' | 'random' | 'qa' | 'live'; export type GetCommentsOptions = { postId: T3; commentId?: T1 | undefined; depth?: number; pageSize?: number; limit?: number; sort?: CommentSort; }; /** Options for submitting a comment body. */ export type CommentSubmissionOptions = { /** The comment body in Markdown. */ text: string; /** * The account used to create the comment. Defaults to the app account. * This option is ignored by {@link Comment.edit}. */ runAs?: 'USER' | 'APP'; } | { /** The comment body as rich text. */ richtext: object | RichTextBuilder; /** * The account used to create the comment. Defaults to the app account. * This option is ignored by {@link Comment.edit}. */ runAs?: 'USER' | 'APP'; }; /** Options for replacing a comment body. */ export type EditCommentOptions = CommentSubmissionOptions; /** Options for replying to a comment. */ export type ReplyToCommentOptions = CommentSubmissionOptions; export type GetCommentsByUserOptions = { username: string; sort?: 'hot' | 'new' | 'top' | 'controversial'; timeframe?: 'hour' | 'day' | 'week' | 'month' | 'year' | 'all'; pageSize?: number; limit?: number; after?: string; before?: string; }; export declare class Comment { #private; get id(): T1; /** The creator's account identifier or `undefined` when unavailable. */ get authorId(): T2 | undefined; /** * The creator's username without the leading `u/`. May be `"[deleted]"` when * the author is unavailable. * * @example "Example_User" */ get authorName(): string; /** The subreddit identifier where the comment was created. */ get subredditId(): T5; /** * The name of the subreddit that contains the comment, without the leading * `r/`. * * @example "AskReddit" */ get subredditName(): string; /** The comment body in Markdown. */ get body(): string; /** The date when the comment was created. */ get createdAt(): Date; /** * The identifier of the comment's parent. * * A top-level comment returns the containing post's `T3`. A reply returns its * parent comment's `T1`. */ get parentId(): T1 | T3; /** The identifier of the post containing the comment. */ get postId(): T3; /** The comment's direct replies. */ get replies(): Listing; /** * The comment's distinction category. * * For example, a comment distinguished by a moderator or administrator * returns `"moderator"` or `"admin"`. `undefined` means no distinction is * available. */ get distinguishedBy(): string | undefined; /** Whether the comment is locked and new replies are disabled. */ get locked(): boolean; /** Whether the comment is pinned to the top of its comment thread. */ get stickied(): boolean; /** Whether the comment has been removed by a moderator. */ get removed(): boolean; /** Whether the comment has been approved by a moderator. */ get approved(): boolean; /** * The moderation approval time as Unix seconds, or `0` when unavailable. * * Use {@link approved} to check the current approval state. Convert a * nonzero value to a `Date` with `new Date(comment.approvedAtUtc * 1000)`. */ get approvedAtUtc(): number; /** * The ban time as Unix seconds, or `0` when unavailable. * * Convert a nonzero value to a `Date` with * `new Date(comment.bannedAtUtc * 1000)`. */ get bannedAtUtc(): number; /** Whether the comment has been marked as spam by a moderator. */ get spam(): boolean; /** Whether the comment body has been edited since it was created. */ get edited(): boolean; /** The number of reports, or `0` when none are available. */ get numReports(): number; /** Whether Crowd Control caused the comment to be collapsed. */ get collapsedBecauseCrowdControl(): boolean; /** The comment's upvotes minus downvotes, or `0` when unavailable. */ get score(): number; /** * The comment's path relative to `https://www.reddit.com`. * * @example "/r/wallstreetbets/comments/abc123/example_post/def456/" */ get permalink(): string; /** User report reasons, or an empty array when none are available. */ get userReportReasons(): string[]; /** Moderator reports and authors, or an empty array when unavailable. */ get modReports(): ModeratorReport[]; /** @deprecated Use {@link modReports} to retain each report's author. */ get modReportReasons(): string[]; /** * The absolute `https://www.reddit.com` URL for the comment. * * @example "https://www.reddit.com/r/wallstreetbets/comments/abc123/post/def456/" */ get url(): string; /** Whether reports on the comment are being ignored. */ get ignoringReports(): boolean; /** The author's subreddit flair, or `undefined` when unavailable. */ get authorFlair(): CommonFlair | undefined; /** Returns the public fields included when the comment is serialized. */ toJSON(): Pick; /** The comment's locked state. */ isLocked(): boolean; /** The comment's approval state. */ isApproved(): boolean; /** The comment's removal state. */ isRemoved(): boolean; /** The comment's spam state. */ isSpam(): boolean; /** The comment's stickied state. */ isStickied(): boolean; /** The comment's distinguished category state. */ isDistinguished(): boolean; /** The comment's edited state. */ isEdited(): boolean; /** The comment's report-ignore state. */ isIgnoringReports(): boolean; /** * Deletes the comment as the app account. * * The `runAs` option is ignored when editing a comment. */ delete(): Promise; /** * Replaces the comment body as the app account, then updates the cached body * and edited state from the response. * * The `runAs` option is ignored when editing a comment. */ edit(opts: Readonly): Promise; /** Approves the comment and updates this instance's moderation state. */ approve(): Promise; /** * Removes the comment and updates this instance's moderation state. * * @param isSpam - Whether to classify the removed comment as spam. */ remove(isSpam?: boolean): Promise; /** * Filters the comment. When a comment is filtered, it is added to the ModQueue for review, and in addition: * - if @param options.keep is `false`, the comment stops being in displayed the subreddit * - if @param options.keep is `true`, the comment is still displayed in the subreddit * * @experimental */ filter(options?: FilterOptions): Promise; /** Disables new replies and updates this instance's locked state. */ lock(): Promise; /** Enables new replies and updates this instance's locked state. */ unlock(): Promise; /** Creates a direct reply to the comment. */ reply(opts: Readonly): Promise; /** Fetches the author's account, or `undefined` if it is unavailable. */ getAuthor(): Promise; /** * Distinguishes the comment as a moderator and updates this instance. * * @param makeSticky - Whether to pin the comment to the top of its thread. */ distinguish(makeSticky?: boolean): Promise; /** * Distinguishes the comment as an employee and updates this instance. * * @param makeSticky - Whether to pin the comment to the top of its thread. */ distinguishAsAdmin(makeSticky?: boolean): Promise; /** * Removes the distinction category and sticky status and updates this * instance. */ undistinguish(): Promise; /** Ignores reports and updates this instance's report-ignore state. */ ignoreReports(): Promise; /** Stops ignoring reports and updates this instance's cached state. */ unignoreReports(): Promise; /** * Snoozes subsequent reports with the same reason from the same users for * seven days. This only works for free-form reports. * * @param reason - The report reason to snooze. */ snoozeReports(reason: string): Promise; /** * Unsnoozes reports with the given reason. This only works for free-form * reports. * * @param reason - The report reason to unsnooze. */ unsnoozeReports(reason: string): Promise; /** * Prevents Crowd Control from collapsing the comment. Other rules can still * collapse it. */ showComment(): Promise; /** * Adds a moderator note explaining why the comment was removed. */ addRemovalNote(opts: Readonly>): Promise; } //# sourceMappingURL=Comment.d.ts.map