From cfd95d9ab2be832a12c95a712efeb643af9f229e Mon Sep 17 00:00:00 2001 From: Cynthia Date: Mon, 5 Dec 2022 21:37:29 -0700 Subject: [PATCH] fedimbed: fix text only posts sending blank messages, cw entire embed if attachments --- src/modules/fedimbed.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/fedimbed.js b/src/modules/fedimbed.js index bbbb602..bcb7ac5 100644 --- a/src/modules/fedimbed.js +++ b/src/modules/fedimbed.js @@ -240,7 +240,7 @@ async function processUrl(msg, url) { let desc = ""; let MAX_LENGTH = 3999; - if (cw != "") { + if (cw != "" && attachments.length == 0) { desc += "\u26a0 " + cw + "\n\n||" + content + "||"; MAX_LENGTH -= 8 - cw.length; } else { @@ -288,6 +288,7 @@ async function processUrl(msg, url) { const embeds = []; + if (attachments.length > 0) { for (const attachment of attachments) { const embed = Object.assign({}, baseEmbed); embed.image = { @@ -295,6 +296,9 @@ async function processUrl(msg, url) { }; embeds.push(embed); } + } else { + embeds.push(baseEmbed); + } // NB: OceanicJS/Oceanic#32 //await msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {}); @@ -309,6 +313,7 @@ async function processUrl(msg, url) { .catch(() => {}); await msg.channel.createMessage({ + content: cw && attachments.length > 0 ? ":warning: " + cw + " || ||"; embeds, allowedMentions: { repliedUser: false,