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;