Skip to content

Commit 0aa1b40

Browse files
committed
refactor: requested change
1 parent e6aef1e commit 0aa1b40

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

packages/discord.js/src/structures/MessagePayload.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,13 @@ class MessagePayload {
197197
waveform: file.waveform,
198198
duration_secs: file.duration,
199199
}));
200+
201+
// Only passable during edits
200202
if (Array.isArray(this.options.attachments)) {
201-
this.options.attachments.push(...(attachments ?? []));
203+
this.options.attachments = this.options.attachments
204+
// Note how we don't check for file body encodable, since we aren't expecting file data here
205+
.map(attachment => (isJSONEncodable(attachment) ? attachment.toJSON() : attachment))
206+
.concat(attachments ?? []);
202207
} else {
203208
this.options.attachments = attachments;
204209
}

packages/discord.js/src/structures/interfaces/TextBasedChannel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class TextBasedChannel {
8888
* @property {Array<(EmbedBuilder|Embed|APIEmbed)>} [embeds] The embeds for the message
8989
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
9090
* (see {@link https://discord.com/developers/docs/resources/message#allowed-mentions-object here} for more details)
91-
* @property {Array<(Attachment|AttachmentPayload|BufferResolvable)>} [files]
91+
* @property {Array<(Attachment|AttachmentPayload|BufferResolvable|FileBodyEncodable<APIAttachment>|Stream)>} [files]
9292
* The files to send with the message.
9393
* @property {Array<(ActionRowBuilder|MessageTopLevelComponent|APIMessageTopLevelComponent)>} [components]
9494
* Action rows containing interactive components for the message (buttons, select menus) and other

packages/discord.js/typings/index.d.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6690,7 +6690,7 @@ export interface BaseMessageOptions {
66906690
)[];
66916691
content?: string;
66926692
embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[];
6693-
files?: readonly (Attachment | AttachmentPayload | BufferResolvable | Stream)[];
6693+
files?: readonly (Attachment | AttachmentPayload | BufferResolvable | FileBodyEncodable<APIAttachment> | Stream)[];
66946694
}
66956695

66966696
export interface MessageOptionsPoll {
@@ -6736,12 +6736,8 @@ export interface GuildForumThreadMessageCreateOptions
67366736
MessageOptionsFlags,
67376737
MessageOptionsStickers {}
67386738

6739-
export interface MessageEditAttachmentData {
6740-
id: Snowflake;
6741-
}
6742-
67436739
export interface MessageEditOptions extends Omit<BaseMessageOptions, 'content'> {
6744-
attachments?: readonly (Attachment | MessageEditAttachmentData)[];
6740+
attachments?: readonly (Attachment | JSONEncodable<APIAttachment>)[];
67456741
content?: string | null;
67466742
flags?:
67476743
| BitFieldResolvable<

0 commit comments

Comments
 (0)