Skip to content

Commit 2ac8be0

Browse files
jaw0r3kalmeidx
authored andcommitted
feat(Attachment): add flags (#9686)
Co-authored-by: Almeida <almeidx@pm.me>
1 parent a222e53 commit 2ac8be0

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/util/AttachmentFlags.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
const BitField = require('./BitField');
4+
5+
/**
6+
* Data structure that makes it easy to interact with an {@link GuildMember#flags} bitfield.
7+
* @extends {BitField}
8+
*/
9+
class AttachmentFlags extends BitField {}
10+
11+
/**
12+
* @name AttachmentFlags
13+
* @kind constructor
14+
* @memberof AttachmentFlags
15+
* @param {BitFieldResolvable} [bits=0] Bit(s) to read from
16+
*/
17+
18+
/**
19+
* Numeric guild member flags. All available properties:
20+
* * `IS_REMIX`
21+
* @type {Object}
22+
* @see {@link https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure-attachment-flags}
23+
*/
24+
AttachmentFlags.FLAGS = {
25+
IS_REMIX: 1 << 2,
26+
};
27+
28+
/**
29+
* Data that can be resolved to give a guild attachment bitfield. This can be:
30+
* * A string (see {@link AttachmentFlags.FLAGS})
31+
* * A attachment flag
32+
* * An instance of AttachmentFlags
33+
* * An Array of AttachmentFlagsResolvable
34+
* @typedef {string|number|AttachmentFlags|AttachmentFlagsResolvable[]} AttachmentFlagsResolvable
35+
*/
36+
37+
module.exports = AttachmentFlags;

typings/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,7 @@ export class MessageAttachment {
17151715
public description: string | null;
17161716
public duration: number | null;
17171717
public ephemeral: boolean;
1718+
public flags: Readonly<AttachmentFlags>;
17181719
public height: number | null;
17191720
public id: Snowflake;
17201721
public name: string | null;
@@ -1731,6 +1732,14 @@ export class MessageAttachment {
17311732
public toJSON(): unknown;
17321733
}
17331734

1735+
export class AttachmentFlags extends BitField<AttachmentFlagsString> {
1736+
public static FLAGS: Record<AttachmentFlagsString, number>;
1737+
public static resolve(bit?: BitFieldResolvable<AttachmentFlagsString, number>): number;
1738+
}
1739+
1740+
export type AttachmentFlagsString =
1741+
| 'IS_REMIX';
1742+
17341743
export class MessageButton extends BaseMessageComponent {
17351744
public constructor(data?: MessageButton | MessageButtonOptions | APIButtonComponent);
17361745
public customId: string | null;

0 commit comments

Comments
 (0)