From 42b99017242f8fe2cfe8edb0279a42d7903b7d28 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sat, 12 Aug 2023 14:29:40 +0200 Subject: [PATCH] feat(Attachment): add flags (#9686) Co-authored-by: Almeida --- src/util/AttachmentFlags.js | 37 +++++++++++++++++++++++++++++++++++++ typings/index.d.ts | 9 +++++++++ 2 files changed, 46 insertions(+) create mode 100644 src/util/AttachmentFlags.js diff --git a/src/util/AttachmentFlags.js b/src/util/AttachmentFlags.js new file mode 100644 index 000000000000..3295ba1b91ef --- /dev/null +++ b/src/util/AttachmentFlags.js @@ -0,0 +1,37 @@ +'use strict'; + +const BitField = require('./BitField'); + +/** + * Data structure that makes it easy to interact with an {@link GuildMember#flags} bitfield. + * @extends {BitField} + */ +class AttachmentFlags extends BitField {} + +/** + * @name AttachmentFlags + * @kind constructor + * @memberof AttachmentFlags + * @param {BitFieldResolvable} [bits=0] Bit(s) to read from + */ + +/** + * Numeric guild member flags. All available properties: + * * `IS_REMIX` + * @type {Object} + * @see {@link https://discord.com/developers/docs/resources/channel#attachment-object-attachment-structure-attachment-flags} + */ +AttachmentFlags.FLAGS = { + IS_REMIX: 1 << 2, +}; + +/** + * Data that can be resolved to give a guild attachment bitfield. This can be: + * * A string (see {@link AttachmentFlags.FLAGS}) + * * A attachment flag + * * An instance of AttachmentFlags + * * An Array of AttachmentFlagsResolvable + * @typedef {string|number|AttachmentFlags|AttachmentFlagsResolvable[]} AttachmentFlagsResolvable + */ + +module.exports = AttachmentFlags; diff --git a/typings/index.d.ts b/typings/index.d.ts index 39fc7eb859a9..aa20f214cf9f 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1714,6 +1714,7 @@ export class MessageAttachment { public description: string | null; public duration: number | null; public ephemeral: boolean; + public flags: Readonly; public height: number | null; public id: Snowflake; public name: string | null; @@ -1730,6 +1731,14 @@ export class MessageAttachment { public toJSON(): unknown; } +export class AttachmentFlags extends BitField { + public static FLAGS: Record; + public static resolve(bit?: BitFieldResolvable): number; +} + +export type AttachmentFlagsString = + | 'IS_REMIX'; + export class MessageButton extends BaseMessageComponent { public constructor(data?: MessageButton | MessageButtonOptions | APIButtonComponent); public customId: string | null;