From 38d370fb18fdbf079b1c91793c0550e77667eccd Mon Sep 17 00:00:00 2001 From: matthewfripp <50251454+matthewfripp@users.noreply.github.com> Date: Mon, 4 Nov 2019 13:44:36 +0000 Subject: [PATCH] feat(MessageAttachment): add spoiler property (#3561) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(MessageAttachment): add spoiler property * typings * Implement suggestions * Make readonly Co-Authored-By: Antonio Román --- src/structures/MessageAttachment.js | 8 ++++++++ typings/index.d.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/structures/MessageAttachment.js b/src/structures/MessageAttachment.js index a4c053036..1af5d1ed8 100644 --- a/src/structures/MessageAttachment.js +++ b/src/structures/MessageAttachment.js @@ -81,6 +81,14 @@ class MessageAttachment { this.width = typeof data.width !== 'undefined' ? data.width : null; } + /** + * Whether or not this attachment has been marked as a spoiler + * @type {boolean} + */ + get spoiler() { + return Util.basename(this.url).startsWith('SPOILER_'); + } + toJSON() { return Util.flatten(this); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 199c5b520..da78cc7e2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1006,6 +1006,7 @@ declare module 'discord.js' { public size: number; public url: string; public width: number | null; + public readonly spoiler: boolean; public setFile(attachment: BufferResolvable | Stream, name?: string): this; public setName(name: string): this; public toJSON(): object;