From 4eae264013ff912c4e8faaa5b88d6878b0f5c310 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Wed, 30 Nov 2022 11:47:25 +0700 Subject: [PATCH] fix: getAttachments --- src/util/Util.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/Util.js b/src/util/Util.js index 3e38b92..6d52858 100644 --- a/src/util/Util.js +++ b/src/util/Util.js @@ -731,7 +731,9 @@ class Util extends null { } static async getAttachments(client, channelId, ...files) { - files = files.flat(2).map((file, i) => ({ + files = files.flat(2); + if (!files.length) return []; + files.map((file, i) => ({ filename: file.name ?? file.attachment?.name ?? file.attachment?.filename ?? 'file.jpg', // 8MB = 8388608 bytes file_size: Math.floor((8_388_608 / 10) * Math.random()),