Skip to content

Commit

Permalink
feat: add MyUserControls::getContributorSubreddits()
Browse files Browse the repository at this point in the history
  • Loading branch information
thislooksfun committed May 2, 2022
1 parent 3a56e77 commit 48f41c0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/reddit/user/my-user/controls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import type { Data } from "../../../helper/types";
import type { Listing } from "../../listing/listing";
import type { Subreddit } from "../../subreddit/object";
import type { RedditObject } from "../../types";
import type { MyUser } from "./object";

Expand All @@ -21,4 +23,21 @@ export class MyUserControls extends BaseUserControls {
const raw: RedditObject = { kind: "t2", data: userData };
return this.client.users.fromRaw(raw) as MyUser;
}

/** @internal */
protected getMySubreddits(where: string): Listing<Subreddit> {
return this.client.subreddits["getSubreddits"](`mine/${where}`);
}

/**
* Get the subreddits the authenticated account is a contributor in.
*
* @note Due to the way Reddit implements Listings, this will only contain the
* first 1000 subreddits.
*
* @returns A Listing of Subreddits.
*/
getContributorSubreddits(): Listing<Subreddit> {
return this.getMySubreddits("contributor");
}
}

0 comments on commit 48f41c0

Please sign in to comment.