mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 19:13:31 +01:00
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:
@@ -81,6 +81,14 @@ class MessageAttachment {
|
|||||||
this.width = typeof data.width !== 'undefined' ? data.width : null;
|
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() {
|
toJSON() {
|
||||||
return Util.flatten(this);
|
return Util.flatten(this);
|
||||||
}
|
}
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -1006,6 +1006,7 @@ declare module 'discord.js' {
|
|||||||
public size: number;
|
public size: number;
|
||||||
public url: string;
|
public url: string;
|
||||||
public width: number | null;
|
public width: number | null;
|
||||||
|
public readonly spoiler: boolean;
|
||||||
public setFile(attachment: BufferResolvable | Stream, name?: string): this;
|
public setFile(attachment: BufferResolvable | Stream, name?: string): this;
|
||||||
public setName(name: string): this;
|
public setName(name: string): this;
|
||||||
public toJSON(): object;
|
public toJSON(): object;
|
||||||
|
|||||||
Reference in New Issue
Block a user