fedimbed: fix text only posts sending blank messages, cw entire embed if attachments

This commit is contained in:
Cynthia Foxwell 2022-12-05 21:37:29 -07:00
parent 8a070bb4b2
commit cfd95d9ab2

View file

@ -240,7 +240,7 @@ async function processUrl(msg, url) {
let desc = ""; let desc = "";
let MAX_LENGTH = 3999; let MAX_LENGTH = 3999;
if (cw != "") { if (cw != "" && attachments.length == 0) {
desc += "\u26a0 " + cw + "\n\n||" + content + "||"; desc += "\u26a0 " + cw + "\n\n||" + content + "||";
MAX_LENGTH -= 8 - cw.length; MAX_LENGTH -= 8 - cw.length;
} else { } else {
@ -288,6 +288,7 @@ async function processUrl(msg, url) {
const embeds = []; const embeds = [];
if (attachments.length > 0) {
for (const attachment of attachments) { for (const attachment of attachments) {
const embed = Object.assign({}, baseEmbed); const embed = Object.assign({}, baseEmbed);
embed.image = { embed.image = {
@ -295,6 +296,9 @@ async function processUrl(msg, url) {
}; };
embeds.push(embed); embeds.push(embed);
} }
} else {
embeds.push(baseEmbed);
}
// NB: OceanicJS/Oceanic#32 // NB: OceanicJS/Oceanic#32
//await msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {}); //await msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {});
@ -309,6 +313,7 @@ async function processUrl(msg, url) {
.catch(() => {}); .catch(() => {});
await msg.channel.createMessage({ await msg.channel.createMessage({
content: cw && attachments.length > 0 ? ":warning: " + cw + " || ||";
embeds, embeds,
allowedMentions: { allowedMentions: {
repliedUser: false, repliedUser: false,