Class PostControls

Various methods to allow you to interact with posts.

Hierarchy (view full)

Methods

  • Approve an item.

    Parameters

    • id: string

      The ID of the item to approve.

    Returns Promise<void>

    A promise that resolves when the item has been approved.

    Note

    This requires the authenticated user to be a moderator of the subreddit with the posts permission.

  • Block the author of an item.

    Parameters

    • id: string

      The ID of the item to block the author of.

    Returns Promise<void>

    A promise that resolves when the request is complete.

    Note

    Apparently this only works if the item is in modmail or the user's inbox, and if it's not the request silently succeeds anyway.

  • Crosspost a post.

    Parameters

    • id: string

      The ID of the post to crosspost.

    • subreddit: string

      The name of the subreddit to crosspost to.

    • title: string

      The title of the crosspost.

    • options: LinkPostOptions = {}

      Any extra options.

    Returns Promise<string>

    A promise that resolves to the ID of the newly created post.

  • Distinguish a post.

    Parameters

    • id: string

      The ID of the post to distinguish.

    Returns Promise<void>

    A promise that resolves when the post has been distinguished.

  • Edit an item.

    Parameters

    • id: string

      The ID of the item to edit.

    • newText: string

      The new text to use.

    Returns Promise<void>

    A promise that resolves when the edit is complete.

  • Fetch a post.

    Parameters

    • id: string

      The id of the post to fetch.

    Returns Promise<Post>

    A promise that resolves to the request post.

    Throws

  • Get the duplicates of a post.

    This is the mechanism that drives the "View discussions in X other communities" button on Reddit.

    Parameters

    • id: string

      The ID of the post to get duplicates of.

    Returns Promise<Listing<Post>>

    A promise that resolves to a listing of posts.

  • Give Reddit gold to the author of an item.

    Parameters

    • id: string

      The ID of the item to gild.

    Returns Promise<void>

    A promise that resolves when the item has been gilded.

  • Hide a post, preventing it from appearing on most listings.

    Parameters

    • id: string

      The ID of the post to hide.

    Returns Promise<void>

    A promise that resolves when the post has been hidden.

  • Ignore any future reports of an item.

    Parameters

    • id: string

      The ID of the item to ignore reports for.

    Returns Promise<void>

    A promise that resolves when the setting has been changed.

    Note

    This requires the authenticated user to be a moderator of the subreddit with the posts permission.

  • Lock an item, preventing non-moderators from being able to post replies.

    Parameters

    • id: string

      The ID of the item to lock.

    Returns Promise<void>

    A promise that resolves when the item has been locked.

  • Mark a post as NSFW.

    Parameters

    • id: string

      The ID of the post to mark NSFW.

    Returns Promise<void>

    A promise that resolves when the post has been marked as NSFW.

  • Mark a post as a spoiler.

    Parameters

    • id: string

      The ID of the post to mark as a spoiler.

    Returns Promise<void>

    A promise that resolves when the post has been marked.

  • Remove an item, optionally marking it as spam.

    Parameters

    • id: string

      The ID of the item to remove.

    • spam: boolean = false

      Whether or not to mark this item as spam. Defaults to false.

    Returns Promise<void>

    A promise that resolves when the item has been removed.

    Note

    This requires the authenticated user to be a moderator of the subreddit with the posts permission.

  • Report an item to the mods.

    The report will be anonymous if you are not a mod of the subreddit. If you are a mod the report will be tied to your username.

    Parameters

    • id: string

      The ID of the item to report.

    • Optional reason: string

      The reason you are reporting the item.

    Returns Promise<void>

    A promise that resolves when the item has been reported.

  • Save an item.

    This will make the item show up at reddit.com/saved.

    Parameters

    • id: string

      The ID of the item to save.

    Returns Promise<void>

    a promise that resolves when the item has been saved.

  • Search Reddit.

    Parameters

    • query: string

      The search query.

    • subreddit: Maybe<string>

      The subreddit to search in.

    • time: TimeRange = "all"

      The time range to search in.

    • sort: SearchSort = "new"

      The way to sort the search results.

    • syntax: SearchSyntax = "plain"

      The search syntax to use.

    • searchSubredditOnly: boolean = false

      Whether or not to restrict the search to the given subreddit. If this is false or if subreddit is falsy this will search all of Reddit.

    Returns Listing<Post>

    A listing of posts.

    Note

    Due to the way Reddit implements Listings, this will only contain the first 1000 posts.

  • Turn contest mode on/off.

    Parameters

    • id: string

      The ID of the post to set contest mode for.

    • enabled: boolean

      Whether to turn contest mode on or off.

    Returns Promise<void>

    A promise that resolves when the post's contest mode has been updated.

  • Set the suggested sort for a post.

    Parameters

    • id: string

      The ID of the post to update the suggested sort for.

    • sort: Maybe<SuggestedSort>

      The new suggested sort. If this is undefined the sort will be cleared.

    Returns Promise<void>

    A promise that resolves when the post's suggested sort has been updated.

  • Sticky a post.

    Parameters

    • id: string

      The ID of the post to sticky.

    • slot: 1 | 2

      The slot to sticky the post to.

    Returns Promise<void>

    A promise that resolves when the post has been stickied.

  • Undistinguish a post.

    Parameters

    • id: string

      The ID of the post to undistinguish.

    Returns Promise<void>

    A promise that resolves when the post has been undistinguished.

  • Unhide a post, allowing it to appear on most listings.

    Parameters

    • id: string

      The ID of the post to hide.

    Returns Promise<void>

    A promise that resolves when the post has been hidden.

  • Unignore any future reports of an item.

    Parameters

    • id: string

      The ID of the item to unignore reports for.

    Returns Promise<void>

    A promise that resolves when the setting has been changed.

    Note

    This requires the authenticated user to be a moderator of the subreddit with the posts permission.

  • Unlock an item, allowing non-moderators to post replies.

    Parameters

    • id: string

      The ID of the item to unlock.

    Returns Promise<void>

    A promise that resolves when the item has been unlocked.

  • Mark a post as not NSFW.

    Parameters

    • id: string

      The ID of the post to unmark.

    Returns Promise<void>

    A promise that resolves when the post has been unmarked.

  • Mark a post as not a spoiler.

    Parameters

    • id: string

      The ID of the post to unmark.

    Returns Promise<void>

    A promise that resolves when the post has been unmarked.

  • Unsave an item.

    This will make the item no longer show up at reddit.com/saved.

    Parameters

    • id: string

      The ID of the item to unsave.

    Returns Promise<void>

    a promise that resolves when the item has been unsaved.

  • Unsticky a post.

    Parameters

    • id: string

      The ID of the post to unsticky.

    Returns Promise<void>

    A promise that resolves when the post has been unstickied.

Generated using TypeDoc