fix(rest): add missing files for editMessage (#3087)

* fix(rest): add missing files for editMessage

* fix(rest): extend attachment test with editMessage

* fix(types):  remove null from files type
This commit is contained in:
NeKz
2023-07-23 22:56:22 +02:00
committed by GitHub
parent d0db3420f7
commit fe00a6f3e3
3 changed files with 22 additions and 2 deletions

View File

@@ -777,7 +777,7 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
},
async editMessage(channelId, messageId, body) {
return await rest.patch<DiscordMessage>(rest.routes.channels.message(channelId, messageId), { body })
return await rest.patch<DiscordMessage>(rest.routes.channels.message(channelId, messageId), { body, files: body.files })
},
async editOriginalInteractionResponse(token, body) {

View File

@@ -59,6 +59,26 @@ describe('Send a message', () => {
expect(fileMsg.id).not.equals(undefined);
expect(fileMsg.content).equals('222');
expect(fileMsg.attachments.length).equals(1);
expect(fileMsg.attachments.at(0)?.filename).equals('application.txt');
expect(fileMsg.attachments.at(0)?.size).equals(11);
const txtFile2 = new Blob(['hello world edit'], { type: 'text/plain' });
const edited = await rest.editMessage(e2ecache.channel.id, fileMsg.id, {
content: '222 edit',
files: [
{
name: 'application_edit.txt',
blob: txtFile2,
},
],
});
expect(edited.id).not.equals(undefined);
expect(edited.content).equals('222 edit');
expect(edited.attachments.length).equals(1);
expect(edited.attachments.at(0)?.filename).equals('application_edit.txt');
expect(edited.attachments.at(0)?.size).equals(16);
})
})

View File

@@ -853,7 +853,7 @@ export interface EditMessage {
/** Edit the flags of the message (only `SUPPRESS_EMBEDS` can currently be set/unset) */
flags?: 4 | null
/** The contents of the files being sent/edited */
files?: FileContent[] | null
files?: FileContent[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** When specified (adding new attachments), attachments which are not provided in this list will be removed. */