Skip to content

Commit

Permalink
feat: add a way to get the users banned from a subreddit
Browse files Browse the repository at this point in the history
  • Loading branch information
thislooksfun committed Mar 27, 2022
1 parent aaf06e7 commit 85831df
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/reddit/subreddit/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ export class SubredditControls extends BaseControls {
await this.unfriend(subreddit, username, "banned");
}

/**
* Get the list of banned users for a subreddit.
*
* @note Due to the way Reddit implements Listings, this will only contain the
* first 1000 banned users.
*
* @param subreddit The name of the subreddit to get banned users for.
*
* @returns A listing of banned users.
*/
getBannedUsers(subreddit: string): Listing<User> {
return this.getAboutListingUsers(subreddit, "banned");
}

/** @internal */
protected getSortedPosts(
subreddit: string | undefined,
Expand Down
12 changes: 12 additions & 0 deletions src/reddit/subreddit/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,4 +938,16 @@ export class Subreddit extends Content implements SubredditData {
async unbanUser(username: string): Promise<void> {
return this.controls.unbanUser(this.displayName, username);
}

/**
* Get the list of banned users for this subreddit.
*
* @note Due to the way Reddit implements Listings, this will only contain the
* first 1000 banned users.
*
* @returns A listing of banned users.
*/
getBannedUsers(): Listing<User> {
return this.controls.getBannedUsers(this.displayName);
}
}

0 comments on commit 85831df

Please sign in to comment.