mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 23:44:46 +12:00
feat(Attachment): add flags
(#9686)
* feat(Attachment): add `flags` * fix: import * fix: flags casing Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
parent
0de071d0a5
commit
692f0fc96d
5 changed files with 52 additions and 0 deletions
|
@ -19,6 +19,7 @@ exports.DiscordjsErrorCodes = require('./errors/ErrorCodes');
|
|||
// Utilities
|
||||
exports.ActivityFlagsBitField = require('./util/ActivityFlagsBitField');
|
||||
exports.ApplicationFlagsBitField = require('./util/ApplicationFlagsBitField');
|
||||
exports.AttachmentFlagsBitField = require('./util/AttachmentFlagsBitField');
|
||||
exports.BaseManager = require('./managers/BaseManager');
|
||||
exports.BitField = require('./util/BitField');
|
||||
exports.ChannelFlagsBitField = require('./util/ChannelFlagsBitField');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const AttachmentFlagsBitField = require('../util/AttachmentFlagsBitField.js');
|
||||
const { basename, flatten } = require('../util/Util');
|
||||
|
||||
/**
|
||||
|
@ -121,6 +122,16 @@ class Attachment {
|
|||
} else {
|
||||
this.waveform ??= null;
|
||||
}
|
||||
|
||||
if ('flags' in data) {
|
||||
/**
|
||||
* The flags of this attachment
|
||||
* @type {Readonly<AttachmentFlagsBitField>}
|
||||
*/
|
||||
this.flags = new AttachmentFlagsBitField(data.flags).freeze();
|
||||
} else {
|
||||
this.flags ??= new AttachmentFlagsBitField().freeze();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -210,6 +210,11 @@
|
|||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/ApplicationRoleConnectionMetadataType}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external AttachmentFlags
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/AttachmentFlags}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @external AutoModerationActionType
|
||||
* @see {@link https://discord-api-types.dev/api/discord-api-types-v10/enum/AutoModerationActionType}
|
||||
|
|
26
packages/discord.js/src/util/AttachmentFlagsBitField.js
Normal file
26
packages/discord.js/src/util/AttachmentFlagsBitField.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
'use strict';
|
||||
|
||||
const { AttachmentFlags } = require('discord-api-types/v10');
|
||||
const BitField = require('./BitField');
|
||||
|
||||
/**
|
||||
* Data structure that makes it easy to interact with an {@link Attachment#flags} bitfield.
|
||||
* @extends {BitField}
|
||||
*/
|
||||
class AttachmentFlagsBitField extends BitField {
|
||||
/**
|
||||
* Numeric attachment flags.
|
||||
* @type {AttachmentFlags}
|
||||
* @memberof AttachmentFlagsBitField
|
||||
*/
|
||||
static Flags = AttachmentFlags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name AttachmentFlagsBitField
|
||||
* @kind constructor
|
||||
* @memberof AttachmentFlagsBitField
|
||||
* @param {BitFieldResolvable} [bits=0] Bit(s) to read from
|
||||
*/
|
||||
|
||||
module.exports = AttachmentFlagsBitField;
|
9
packages/discord.js/typings/index.d.ts
vendored
9
packages/discord.js/typings/index.d.ts
vendored
|
@ -166,6 +166,7 @@ import {
|
|||
APIGuildOnboardingPrompt,
|
||||
APIGuildOnboardingPromptOption,
|
||||
GuildOnboardingPromptType,
|
||||
AttachmentFlags,
|
||||
} from 'discord-api-types/v10';
|
||||
import { ChildProcess } from 'node:child_process';
|
||||
import { EventEmitter } from 'node:events';
|
||||
|
@ -2070,6 +2071,7 @@ export class Attachment {
|
|||
public description: string | null;
|
||||
public duration: number | null;
|
||||
public ephemeral: boolean;
|
||||
public flags: AttachmentFlagsBitField;
|
||||
public height: number | null;
|
||||
public id: Snowflake;
|
||||
public name: string;
|
||||
|
@ -2082,6 +2084,13 @@ export class Attachment {
|
|||
public toJSON(): unknown;
|
||||
}
|
||||
|
||||
export type AttachmentFlagsString = keyof typeof AttachmentFlags;
|
||||
|
||||
export class AttachmentFlagsBitField extends BitField<AttachmentFlagsString> {
|
||||
public static Flags: Record<AttachmentFlagsString, number>;
|
||||
public static resolve(bit?: BitFieldResolvable<AttachmentFlagsString, number>): number;
|
||||
}
|
||||
|
||||
export class MessageCollector extends Collector<Snowflake, Message, [Collection<Snowflake, Message>]> {
|
||||
public constructor(channel: TextBasedChannel, options?: MessageCollectorOptions);
|
||||
private _handleChannelDeletion(channel: NonThreadGuildBasedChannel): void;
|
||||
|
|
Loading…
Reference in a new issue