diff --git a/src/structures/MessageAttachment.js b/src/structures/MessageAttachment.js index dd8b8a380..6db15c830 100644 --- a/src/structures/MessageAttachment.js +++ b/src/structures/MessageAttachment.js @@ -1,3 +1,5 @@ +const { basename } = require('path'); + /** * Represents an attachment in a message. */ @@ -63,6 +65,15 @@ class MessageAttachment { */ this.width = data.width; } + + /** + * Whether or not this attachment has been marked as a spoiler + * @type {boolean} + * @readonly + */ + get spoiler() { + return basename(this.url).startsWith('SPOILER_'); + } } module.exports = MessageAttachment; diff --git a/typings/index.d.ts b/typings/index.d.ts index b1f9c2b1c..d31af2c9f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -797,6 +797,7 @@ declare module 'discord.js' { public id: Snowflake; public message: Message; public proxyURL: string; + public readonly spoiler: boolean; public url: string; public width: number; }