Class SubredditControls

Various methods to allow you to interact with subreddits.

Hierarchy (view full)

Methods

  • Accept a moderator invite.

    Parameters

    • subreddit: string

      The name of the subreddit to accept the invite for.

    Returns Promise<void>

    A promise that resolves when the invite has been accepted.

  • Add an approved poster.

    Parameters

    • subreddit: string

      The name of the subreddit to add the contributor to.

    • username: string

      The username of the user to add.

    Returns Promise<void>

    A promise that resolves when the contributor has been added.

  • Add a user to the list of approved wiki editors.

    Parameters

    • subreddit: string

      The name of the subreddit to add the user to.

    • username: string

      The username of the user to add.

    Returns Promise<void>

    A promise that resolves when the wiki editor has been added.

  • Ban a user from a subreddit.

    Parameters

    • subreddit: string

      The name of the subreddit to ban the user from.

    • username: string

      The username of the user to ban.

    • options: BanOptions = {}

      Any additional options for the ban.

    Returns Promise<void>

    A promise that resolves when the user has been banned.

  • Get the list of banned users for a subreddit.

    Parameters

    • subreddit: string

      The name of the subreddit to get banned users for.

    Returns Listing<BannedUser>

    A listing of banned users.

    Note

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

  • Get the posts in a subreddit, sorted by controversial.

    Parameters

    • Optional subreddit: string

      The name of the subreddit. If this is left off it will query the front page of Reddit.

    • time: TimeRange = "all"

      The time scale to filter by.

    Returns Listing<Post>

    A listing of posts, with the most controversial ones first.

    Note

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

  • Get the posts in a subreddit, sorted by hot.

    Parameters

    • Optional subreddit: string

      The name of the subreddit. If this is left off it will query the front page of Reddit.

    Returns Listing<Post>

    A listing of posts, with the hottest ones first.

    Note

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

  • Get the list of moderators for a subreddit.

    Parameters

    • subreddit: string

      The name of the subreddit to get moderators for.

    Returns Promise<Moderator[]>

    A listing of moderators.

  • Get the posts in a subreddit, sorted by new.

    Parameters

    • Optional subreddit: string

      The name of the subreddit. If this is left off it will query the front page of Reddit.

    Returns Listing<Post>

    A listing of posts, with the newest ones first.

    Note

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

  • Get the ID of a random post.

    Parameters

    • Optional subreddit: string

      The name of the subreddit. If this is left off it will query the front page of Reddit.

    Returns Promise<string>

    A promise that resolves to a random post ID.

  • Get the posts in a subreddit, sorted by rising.

    Parameters

    • Optional subreddit: string

      The name of the subreddit. If this is left off it will query the front page of Reddit.

    Returns Listing<Post>

    A listing of posts, with the rising ones first.

    Note

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

  • Get a Listing of all the comments in a subreddit.

    Parameters

    • subreddit: string

      The subreddit to get comments from. If this is not provided comments will be fetched from the front page of Reddit.

    • sort: "new" = "new"

      How to sort the comments.

    Returns Listing<Comment>

    A sorted Listing of comments.

    Note

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

  • Get the posts in a subreddit, sorted by top.

    Parameters

    • Optional subreddit: string

      The name of the subreddit. If this is left off it will query the front page of Reddit.

    • time: TimeRange = "all"

      The time scale to filter by.

    Returns Listing<Post>

    A listing of posts, with the top rated ones first.

    Note

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

  • Get the list of posts that have not been moderated from a subreddit.

    Parameters

    • subreddit: string

      The name of the subreddit.

    Returns Listing<Post>

    A listing of posts that have not been moderated.

  • Get the list of wikibanned users for a subreddit.

    Parameters

    • subreddit: string

      The name of the subreddit to get wikibanned users for.

    Returns Listing<BannedUser>

    A listing of wikibanned users.

    Note

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

  • Mute a user in a subreddit.

    This prevents the user from sending modmail to the subreddit for 72 hours.

    Parameters

    • subreddit: string

      The name of the subreddit to mute the user in.

    • username: string

      The username of the user to mute.

    Returns Promise<void>

  • Namespace an id with the proper prefix for its type.

    Parameters

    • id: string

      The ID to namespace.

    Returns string

    The namespaced version of the id.

  • Submit a crosspost.

    Parameters

    • subreddit: string

      The subreddit to submit the post to.

    • title: string

      The title of the post.

    • postID: string

      The ID of the post to crosspost.

    • options: LinkPostOptions = {}

      Any extra options.

    Returns Promise<string>

    A promise that resolves to the ID of the new post.

  • Submit an image post.

    Parameters

    • subreddit: string

      The subreddit to submit the post to.

    • title: string

      The title of the post.

    • imageFile: Blob

      The image file to post.

    • imageFileName: string

      The name of the image file.

    • noWebsockets: boolean = false

      Whether to disable websockets for the image.

    • options: LinkPostOptions = {}

      Any extra options.

    Returns Promise<undefined | string>

    A promise that resolves to the ID of the new post or undefined

  • Submit a link post.

    Parameters

    • subreddit: string

      The subreddit to submit the post to.

    • title: string

      The title of the post.

    • url: string

      The url to link to.

    • options: LinkPostOptions = {}

      Any extra options.

    Returns Promise<string>

    A promise that resolves to the ID of the new post.

  • Submit a text post.

    Parameters

    • subreddit: string

      The subreddit to submit the post to.

    • title: string

      The title of the post.

    • Optional body: string

      The body of the post.

    • options: TextPostOptions = {}

      Any extra options.

    Returns Promise<string>

    A promise that resolves to the ID of the new post.

  • Submit a video post.

    Parameters

    • subreddit: string

      The subreddit to submit the post to.

    • title: string

      The title of the post.

    • videoFile: Blob

      The video file to post.

    • videoFileName: string

      The name of the video file.

    • thumbnailFile: Blob

      The thumbnail file to use.

    • thumbnailFileName: string

      The name of the thumbnail file.

    • videoGif: boolean = false

      Whether the video is a gif.

    • noWebsockets: boolean = false

      Whether to disable websockets for the video.

    • options: LinkPostOptions = {}

      Any extra options.

    Returns Promise<undefined | string>

    A promise that resolves to the ID of the new post or undefined

  • Remove an approved poster.

    Parameters

    • subreddit: string

      The name of the subreddit to remove the contributor from.

    • username: string

      The username of the user to remove.

    Returns Promise<void>

    A promise that resolves when the contributor has been removed.

  • Remove a user from the list of approved wiki editors.

    Parameters

    • subreddit: string

      The name of the subreddit to remove the user from.

    • username: string

      The username of the user to remove.

    Returns Promise<void>

    A promise that resolves when the wiki editor has been removed.

  • Search in a subreddit.

    Parameters

    • subreddit: string

      The subreddit to search in.

    • query: string

      The search query.

    • time: TimeRange = "all"

      The time range to search in.

    • sort: SearchSort = "relevance"

      The way to sort the search results.

    • syntax: SearchSyntax = "plain"

      The search syntax to use.

    Returns Listing<Post>

    A listing of posts.

    Note

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

  • Unban a user from a subreddit.

    Parameters

    • subreddit: string

      The name of the subreddit to unban the user from.

    • username: string

      The username of the user to unban.

    Returns Promise<void>

    A promise that resolves when the user has been unbanned.

  • Unmute a user in a subreddit.

    Parameters

    • subreddit: string

      The name of the subreddit to unmute the user in.

    • username: string

      The username of the user to unmute.

    Returns Promise<void>

  • Unban a user from editing a subreddit's wiki

    Parameters

    • subreddit: string

      The name of the subreddit to wikiban the user in.

    • username: string

      The username of the user to wikiban.

    Returns Promise<void>

  • Ban a user from editing a subreddit's wiki.

    Parameters

    • subreddit: string

      The name of the subreddit to wikiban the user in.

    • username: string

      The username of the user to wikiban.

    Returns Promise<void>