Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Message): allow editing files into messages #5718

Merged
merged 1 commit into from May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -3184,12 +3184,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