Skip to content

Commit

Permalink
fix: make SubredditControls::getSortedComments() work
Browse files Browse the repository at this point in the history
Previously it would crash.
  • Loading branch information
thislooksfun committed Mar 27, 2022
1 parent a89c115 commit bf0518e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/reddit/subreddit/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,22 +596,22 @@ export class SubredditControls extends BaseControls {
return this.client.posts.search(query, subreddit, time, sort, syntax, true);
}

// TODO: allow other sorting
/**
* Get a Listing of all the comments in a subreddit.
*
* @note Due to the way Reddit implements Listings, this will only contain the
* first 1000 posts.
* first 1000 comments.
*
* @param subreddit The subreddit to get comments from. If this is not
* provided comments will be fetched from the front page of Reddit.
* @param sort How to sort the comments.
*
* @returns A sorted Listing of comments.
*/
// TODO: allow other sorting?
getSortedComments(subreddit: string, sort: "new" = "new"): Listing<Comment> {
const url = subreddit ? `r/${subreddit}/` : "";
const request = { url: `${url}${sort}`, query: { sort } };
const request = { url: `${url}comments`, query: { sort } };
const context = { request, client: this.client };
return new CommentListing(fakeListingAfter(""), context);
}
Expand Down

0 comments on commit bf0518e

Please sign in to comment.