Skip to content

Commit

Permalink
feat: add blockAuthor()
Browse files Browse the repository at this point in the history
  • Loading branch information
thislooksfun committed Apr 8, 2021
1 parent b5f09ea commit 58feff1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/controls/replyable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import BaseControls from "./base";

/** The base controls for all content that you can reply to. */
export default abstract class ReplyableControls extends BaseControls {
/**
* Block the author of an item.
*
* @note Apparently this only works if the item is in modmail or the user's
* inbox, and if it's not the request silently succeeds anyway.
*
* @param id The ID of the item to block the author of.
*
* @returns A promise that resolves when the request is complete.
*/
async blockAuthor(id: string): Promise<void> {
await this.client.post("api/block", { id: this.namespace(id) });
}

/**
* Report an item to the mods.
*
Expand Down
12 changes: 12 additions & 0 deletions src/objects/replyable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ export default abstract class Replyable extends Content {
this.controls = controls;
}

/**
* Block the author of this item.
*
* @note Apparently this only works if this item is in modmail or the user's
* inbox, and if it's not the request silently succeeds anyway.
*
* @returns A promise that resolves when the request is complete.
*/
async blockAuthor(): Promise<void> {
return this.controls.blockAuthor(this.id);
}

/**
* Report this item to the mods.
*
Expand Down

0 comments on commit 58feff1

Please sign in to comment.