Skip to content

Commit

Permalink
feat(Message): allow removing attachments (#5557)
Browse files Browse the repository at this point in the history
  • Loading branch information
vaporoxx authored May 10, 2021
1 parent 3392eb7 commit ca9e5a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/structures/APIMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class APIMessage {
typeof content === 'undefined' && typeof message_reference === 'undefined' ? undefined : allowedMentions,
flags,
message_reference,
attachments: this.options.attachments,
};
return this;
}
Expand Down
9 changes: 9 additions & 0 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ class Message extends Base {
* @property {string|boolean} [code] Language for optional codeblock formatting to apply
* @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
* @property {MessageFlags} [flags] Which flags to set for the message. Only `SUPPRESS_EMBEDS` can be edited.
* @property {MessageAttachment[]} [attachments] The new attachments of the message (can only be removed, not added)
*/

/**
Expand Down Expand Up @@ -656,6 +657,14 @@ class Message extends Base {
return this.edit({ flags });
}

/**
* Removes the attachments from this message.
* @returns {Promise<Message>}
*/
removeAttachments() {
return this.edit({ attachments: [] });
}

/**
* Used mainly internally. Whether two messages are identical in properties. If you want to compare messages
* without checking all the properties, use `message.id === message2.id`, which is much more efficient. This
Expand Down
2 changes: 2 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,7 @@ declare module 'discord.js' {
public fetch(force?: boolean): Promise<Message>;
public pin(options?: { reason?: string }): Promise<Message>;
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
public removeAttachments(): Promise<Message>;
public reply(
content: APIMessageContentResolvable | (MessageOptions & { split?: false }) | MessageAdditions,
): Promise<Message>;
Expand Down Expand Up @@ -3099,6 +3100,7 @@ declare module 'discord.js' {
code?: string | boolean;
flags?: BitFieldResolvable<MessageFlagsString, number>;
allowedMentions?: MessageMentionOptions;
attachments?: MessageAttachment[];
}

interface MessageEmbedAuthor {
Expand Down

0 comments on commit ca9e5a0

Please sign in to comment.