Skip to content

Commit

Permalink
feat: add a way to manage wikibanned users in a subreddit
Browse files Browse the repository at this point in the history
  • Loading branch information
thislooksfun committed Mar 27, 2022
1 parent d057dc0 commit 8abe658
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/reddit/subreddit/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,40 @@ export class SubredditControls extends BaseControls {
return this.getAboutListingUsers(subreddit, "muted");
}

/**
* Ban a user from editing a subreddit's wiki.
*
* @param subreddit The name of the subreddit to wikiban the user in.
* @param username The username of the user to wikiban.
*/
async wikibanUser(subreddit: string, username: string): Promise<void> {
await this.friend(subreddit, username, "wikibanned");
}

/**
* Unban a user from editing a subreddit's wiki
*
* @param subreddit The name of the subreddit to wikiban the user in.
* @param username The username of the user to wikiban.
*/
async unwikibanUser(subreddit: string, username: string): Promise<void> {
await this.unfriend(subreddit, username, "wikibanned");
}

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

/** @internal */
protected getSortedPosts(
subreddit: string | undefined,
Expand Down
30 changes: 30 additions & 0 deletions src/reddit/subreddit/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,36 @@ export class Subreddit extends Content implements SubredditData {
return this.controls.getMutedUsers(this.displayName);
}

/**
* Ban a user from editing this subreddit's wiki.
*
* @param username The username of the user to wikiban.
*/
async wikibanUser(username: string): Promise<void> {
return this.controls.wikibanUser(this.displayName, username);
}

/**
* Unban a user from editing this subreddit's wiki
*
* @param username The username of the user to wikiban.
*/
async unwikibanUser(username: string): Promise<void> {
return this.controls.unwikibanUser(this.displayName, username);
}

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

/**
* Ban a user from this subreddit.
*
Expand Down

0 comments on commit 8abe658

Please sign in to comment.