Skip to content

Commit

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

/**
* Remove an item, optionally marking it as spam.
*
* @param id The ID of the item to remove.
* @param spam Whether or not to mark this item as spam. Defaults to false.
*
* @returns A promise that resolves when the item has been removed.
*/
async remove(id: string, spam: boolean = false): Promise<void> {
return this.client.post("api/remove", { id: this.namespace(id), spam });
}

/**
* Give Reddit gold to the author of an item.
*
Expand Down
11 changes: 11 additions & 0 deletions src/objects/voteable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,17 @@ export default abstract class Voteable extends Content implements VoteableData {
return this.controls.delete(this.id);
}

/**
* Remove this item, optionally marking it as spam.
*
* @param spam Whether or not to mark this item as spam. Defaults to false.
*
* @returns A promise that resolves when this item has been removed.
*/
async remove(spam: boolean = false): Promise<void> {
return this.controls.remove(this.id, spam);
}

/**
* Give Reddit gold to the author of this item.
*
Expand Down

0 comments on commit 6e77a74

Please sign in to comment.