mirror of
https://github.com/danbulant/discord.js
synced 2026-06-09 17:52:55 +00:00
feat(MessageAttachment): add spoiler getter (#3713)
This commit is contained in:
parent
a505a55e03
commit
4ca18647ba
2 changed files with 12 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
const { basename } = require('path');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an attachment in a message.
|
* Represents an attachment in a message.
|
||||||
*/
|
*/
|
||||||
|
|
@ -63,6 +65,15 @@ class MessageAttachment {
|
||||||
*/
|
*/
|
||||||
this.width = data.width;
|
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;
|
module.exports = MessageAttachment;
|
||||||
|
|
|
||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
|
|
@ -797,6 +797,7 @@ declare module 'discord.js' {
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public message: Message;
|
public message: Message;
|
||||||
public proxyURL: string;
|
public proxyURL: string;
|
||||||
|
public readonly spoiler: boolean;
|
||||||
public url: string;
|
public url: string;
|
||||||
public width: number;
|
public width: number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue