Skip to content

Commit

Permalink
feat(Message): allow editing files into messages (#5718)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceEEC committed May 31, 2021
1 parent 256d1b0 commit b212b64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/managers/MessageManager.js
Expand Up @@ -124,8 +124,10 @@ class MessageManager extends BaseManager {
message = this.resolveID(message);
if (!message) throw new TypeError('INVALID_TYPE', 'message', 'MessageResolvable');

const { data } = (options instanceof APIMessage ? options : APIMessage.create(this, options)).resolveData();
const d = await this.client.api.channels[this.channel.id].messages[message].patch({ data });
const { data, files } = await (options instanceof APIMessage ? options : APIMessage.create(this, options))
.resolveData()
.resolveFiles();
const d = await this.client.api.channels[this.channel.id].messages[message].patch({ data, files });

if (this.cache.has(message)) {
const clone = this.cache.get(message)._clone();
Expand Down
4 changes: 3 additions & 1 deletion src/structures/Message.js
Expand Up @@ -479,7 +479,9 @@ 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)
* @property {MessageAttachment[]} [attachments] An array of attachments to keep,
* all attachments will be kept if omitted
* @property {FileOptions[]|BufferResolvable[]|MessageAttachment[]} [files] Files to add to the message
*/

/**
Expand Down
3 changes: 2 additions & 1 deletion typings/index.d.ts
Expand Up @@ -3204,12 +3204,13 @@ declare module 'discord.js' {
}

interface MessageEditOptions {
attachments?: MessageAttachment[];
content?: StringResolvable;
embed?: MessageEmbed | MessageEmbedOptions | null;
code?: string | boolean;
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
flags?: BitFieldResolvable<MessageFlagsString, number>;
allowedMentions?: MessageMentionOptions;
attachments?: MessageAttachment[];
}

interface MessageEmbedAuthor {
Expand Down

0 comments on commit b212b64

Please sign in to comment.