feat(MessageAttachment): add spoiler property (#3561)

* feat(MessageAttachment): add spoiler property

* typings

* Implement suggestions

* Make readonly

Co-Authored-By: Antonio Román <kyradiscord@gmail.com>
This commit is contained in:
matthewfripp
2019-11-04 13:44:36 +00:00
committed by Crawl
parent cc466fa4b9
commit 38d370fb18
2 changed files with 9 additions and 0 deletions

View File

@@ -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);
}

1
typings/index.d.ts vendored
View File

@@ -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;