Skip to content

Commit

Permalink
feat: add a function to approve an item
Browse files Browse the repository at this point in the history
  • Loading branch information
thislooksfun committed Mar 26, 2021
1 parent 52df097 commit 11cde28
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/controls/voteable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ export default abstract class VoteableControls extends ReplyableControls {
return this.client.post("api/del", { id: this.namespace(id) });
}

/**
* Approve an item.
*
* @note This requires the authenticated user to be a moderator of the
* subreddit with the `posts` permission.
*
* @param id The ID of the item to approve.
*
* @returns A promise that resolves when the item has been approved.
*/
async approve(id: string): Promise<void> {
return this.client.post("api/approve", { id: this.namespace(id) });
}

/**
* Remove an item, optionally marking it as spam.
*
Expand Down
12 changes: 12 additions & 0 deletions src/objects/voteable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,18 @@ export default abstract class Voteable
return this.controls.delete(this.id);
}

/**
* Approve this item.
*
* @note This requires the authenticated user to be a moderator of the
* subreddit with the `posts` permission.
*
* @returns A promise that resolves when the item has been approved.
*/
async approve(): Promise<void> {
return this.controls.approve(this.id);
}

/**
* Remove this item, optionally marking it as spam.
*
Expand Down

0 comments on commit 11cde28

Please sign in to comment.