From ac219dccbcaace3d83da5480717750f29ec64adb Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Thu, 19 Aug 2021 02:40:22 +0200 Subject: [PATCH] Fix `Cannot read property 'pipe' of undefined` error if no file exists --- backend/src/plugins/Post/util/postMessage.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/Post/util/postMessage.ts b/backend/src/plugins/Post/util/postMessage.ts index 9d4b67f4..f8b375b0 100644 --- a/backend/src/plugins/Post/util/postMessage.ts +++ b/backend/src/plugins/Post/util/postMessage.ts @@ -38,7 +38,12 @@ export async function postMessage( }; } - const createdMsg = await channel.send({ ...content, files: [file] }); + let createdMsg; + if (file) { + createdMsg = await channel.send({ ...content, files: [file.file] }); + } else { + createdMsg = await channel.send(content); + } pluginData.state.savedMessages.setPermanent(createdMsg.id); if (downloadedAttachment) {