Skip to content

Commit c3a8425

Browse files
committed
Add embed flags & missing attachment properties
discord/discord-api-docs#7353
1 parent 16e80b5 commit c3a8425

File tree

4 files changed

+56
-16
lines changed

4 files changed

+56
-16
lines changed

lib/Constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,7 @@ export enum AttachmentFlags {
13501350
IS_REMIX = 1 << 2,
13511351
IS_SPOILER = 1 << 3,
13521352
CONTAINS_EXPLICIT_MEDIA = 1 << 4,
1353+
IS_ANIMATED = 1 << 5,
13531354
}
13541355

13551356
export enum SKUTypes {
@@ -1528,6 +1529,15 @@ export const ApplicationEventWebhookEventTypes = [
15281529
] as const;
15291530
export type ApplicationEventWebhookEventType = typeof ApplicationEventWebhookEventTypes[number];
15301531

1532+
export enum EmbedFlags {
1533+
CONTAINS_EXPLICIT_MEDIA = 1 << 4,
1534+
IS_CONTENT_INVENTORY_ENTRY = 1 << 5,
1535+
}
1536+
1537+
export enum EmbedMediaFlags {
1538+
IS_ANIMATED = 1 << 5,
1539+
}
1540+
15311541
// entries are intentionally not aligned
15321542
/** The error codes that can be received. See [Discord's Documentation](https://discord.com/developers/docs/topics/opcodes-and-status-codes#json). */
15331543
export enum JSONErrorCodes {

lib/structures/Attachment.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
/** @module Attachment */
22
import Base from "./Base";
3+
import type User from "./User";
4+
import Application from "./Application";
35
import type Client from "../Client";
46
import type { RawAttachment } from "../types/channels";
57
import type { JSONAttachment } from "../types/json";
68

79
/** Represents a file attachment. */
810
export default class Attachment extends Base {
11+
/** For Clips, the application in the stream, if recognized. */
12+
application?: Application;
13+
/** For Clips, when the clip was created. */
14+
clipCreatedAt?: Date;
15+
/** For Clips, array of users who were in the stream. */
16+
clipParticipants?: Array<User>;
917
/** The mime type of this attachment. */
1018
contentType?: string;
1119
/** The description of this attachment. */
@@ -34,6 +42,9 @@ export default class Attachment extends Base {
3442
width?: number;
3543
constructor(data: RawAttachment, client: Client) {
3644
super(data.id, client);
45+
this.application = data.application ? new Application(data.application, client) : undefined;
46+
this.clipCreatedAt = data.clip_created_at ? new Date(data.clip_created_at) : undefined;
47+
this.clipParticipants = data.clip_participants ? data.clip_participants.map(user => client.users.update(user)) : undefined;
3748
this.contentType = data.content_type;
3849
this.description = data.description;
3950
this.durationSecs = data.duration_secs;

lib/types/channels.d.ts

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @module Types/Channels */
22
import type { NullablePartialEmoji, PartialEmoji, RawInviteGuild, RawMember } from "./guilds";
3-
import type { RawApplication, RawPartialApplication } from "./applications";
3+
import type { RESTApplication, RawApplication, RawPartialApplication } from "./applications";
44
import type { RawUser, RawUserWithMember } from "./users";
55
import type { File } from "./request-handler";
66
import type { RawScheduledEvent } from "./scheduled-events";
@@ -307,7 +307,7 @@ export interface CreateMessageOptions {
307307
enforceNonce?: boolean;
308308
/** The files to send. */
309309
files?: Array<File>;
310-
/** The [flags](https://discord.com/developers/docs/resources/channel#message-object-message-flags) to send with the message. */
310+
/** The {@link Constants.MessageFlags | Message Flags} to send with the message. */
311311
flags?: number;
312312
/** Reply to a message. */
313313
messageReference?: MessageReference;
@@ -355,6 +355,8 @@ export interface EmbedBase extends EmbedOptionsBase {
355355
export interface RawEmbed extends EmbedBase {
356356
author?: RawEmbedAuthor;
357357
fields?: Array<EmbedField>;
358+
/** The {@link Constants.EmbedFlags | Embed Flags} for the embed. */
359+
flags?: number;
358360
footer?: RawEmbedFooter;
359361
image?: RawEmbedImage;
360362
provider?: EmbedProvider;
@@ -365,6 +367,8 @@ export interface RawEmbed extends EmbedBase {
365367
export interface Embed extends EmbedBase {
366368
author?: EmbedAuthor;
367369
fields?: Array<EmbedField>;
370+
/** The {@link Constants.EmbedFlags | Embed Flags} for the embed. */
371+
flags?: number;
368372
footer?: EmbedFooter;
369373
image?: EmbedImage;
370374
provider?: EmbedProvider;
@@ -384,36 +388,41 @@ export interface RawEmbedAuthor extends EmbedAuthorBase {
384388
proxy_icon_url?: string;
385389
}
386390

387-
export interface EmbedAuthorOptions extends EmbedAuthorBase {
391+
export interface EmbedAuthor extends EmbedAuthorOptions {
388392
iconURL?: string;
393+
proxyIconURL?: string;
389394
}
390395

391396
export interface RawEmbedAuthorOptions extends EmbedAuthorBase {
392397
icon_url?: string;
393398
}
394399

395-
export interface EmbedAuthor extends EmbedAuthorOptions {
400+
export interface EmbedAuthorOptions extends EmbedAuthorBase {
396401
iconURL?: string;
397-
proxyIconURL?: string;
398402
}
403+
399404
export interface EmbedFooterBase {
400405
text: string;
401406
}
402407

403-
export interface EmbedFooterOptions extends EmbedFooterBase {
404-
iconURL?: string;
405-
}
406-
407408
export interface RawEmbedFooterOptions extends EmbedFooterBase {
408409
icon_url?: string;
409410
}
410411

412+
export interface EmbedFooterOptions extends EmbedFooterBase {
413+
iconURL?: string;
414+
}
415+
411416
export interface RawEmbedFooter extends EmbedFooterBase {
417+
/** The {@link Constants.EmbedMediaFlags | Embed Media Flags} for the media. */
418+
flags?: number;
412419
icon_url?: string;
413420
proxy_icon_url?: string;
414421
}
415422

416423
export interface EmbedFooter extends EmbedFooterOptions {
424+
/** The {@link Constants.EmbedMediaFlags | Embed Media Flags} for the media. */
425+
flags?: number;
417426
iconURL?: string;
418427
proxyIconURL?: string;
419428
}
@@ -424,17 +433,21 @@ export interface EmbedImageBase {
424433
}
425434

426435
export interface RawEmbedImage extends EmbedImageBase, EmbedImageOptions {
436+
/** The {@link Constants.EmbedMediaFlags | Embed Media Flags} for the media. */
437+
flags?: number;
427438
proxy_url?: string;
428439
}
429440

430-
export interface EmbedImageOptions {
431-
url: string;
432-
}
433-
434441
export interface EmbedImage extends EmbedImageBase, EmbedImageOptions {
442+
/** The {@link Constants.EmbedMediaFlags | Embed Media Flags} for the media. */
443+
flags?: number;
435444
proxyURL?: string;
436445
}
437446

447+
export interface EmbedImageOptions {
448+
url: string;
449+
}
450+
438451
export interface EmbedField {
439452
inline?: boolean;
440453
name: string;
@@ -653,6 +666,9 @@ export interface TextInput {
653666
}
654667

655668
export interface RawAttachment {
669+
application?: RESTApplication;
670+
clip_created_at?: string;
671+
clip_participants?: Array<RawUser>;
656672
content_type?: string;
657673
description?: string;
658674
duration_secs?: number;

lib/util/Util.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,17 +422,20 @@ export default class Util {
422422
name: field.name,
423423
value: field.value
424424
})),
425+
flags: embed.flags,
425426
footer: embed.footer === undefined ? undefined : {
426-
text: embed.footer.text,
427+
flags: embed.footer.flags,
427428
iconURL: embed.footer.icon_url,
428-
proxyIconURL: embed.footer.proxy_icon_url
429+
proxyIconURL: embed.footer.proxy_icon_url,
430+
text: embed.footer.text
429431
},
430432
timestamp: embed.timestamp,
431433
title: embed.title,
432434
image: embed.image === undefined ? undefined : {
433-
url: embed.image.url,
435+
flags: embed.image.flags,
434436
height: embed.image.height,
435437
proxyURL: embed.image.proxy_url,
438+
url: embed.image.url,
436439
width: embed.image.width
437440
},
438441
provider: embed.provider === undefined ? undefined : {

0 commit comments

Comments
 (0)