fedimbed+codePreviews: fix embed suppression not working due to oversight in oceanic

This commit is contained in:
Cynthia Foxwell 2022-12-05 20:35:48 -07:00
parent a15962c110
commit 13b6357640
2 changed files with 31 additions and 4 deletions

View file

@ -106,7 +106,18 @@ events.add("messageCreate", "codePreviews", async function (msg) {
if (out.length > 2000) return;
if (out !== "") {
await msg.edit({flags: 1 << 2}).catch(() => {});
// NB: OceanicJS/Oceanic#32
//await msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {});
await hf.bot.rest
.authRequest({
method: "PATCH",
path: Routes.CHANNEL_MESSAGE(msg.channel.id, msg.id),
json: {
flags: MessageFlags.SUPPRESS_EMBEDS,
},
})
.catch(() => {});
await msg.channel.createMessage({
content: out,
allowedMentions: {

View file

@ -1,3 +1,5 @@
const {MessageFlags, Routes} = require("oceanic.js");
const events = require("../lib/events.js");
const logger = require("../lib/logger.js");
const {hasFlag} = require("../lib/guildSettings.js");
@ -68,7 +70,7 @@ async function processUrl(msg, url) {
.replace(/^(.)/, (_, c) => c.toUpperCase());
const attachments = [];
let content, cw, author;
let content, cw, author, timestamp;
// Fetch post
const rawPostData = await fetch(url, {
@ -149,7 +151,10 @@ async function processUrl(msg, url) {
}
}
} else {
logger.error("fedimbed", `Redirect from /object did not give us /notice. (${urlObj.pathname})`);
logger.error(
"fedimbed",
`Redirect from /object did not give us /notice. (${urlObj.pathname})`
);
}
} else {
content = postData.content;
@ -260,7 +265,18 @@ async function processUrl(msg, url) {
embeds.push(embed);
}
await msg.edit({flags: 1 << 2}).catch(() => {});
// NB: OceanicJS/Oceanic#32
//await msg.edit({flags: MessageFlags.SUPPRESS_EMBEDS}).catch(() => {});
await hf.bot.rest
.authRequest({
method: "PATCH",
path: Routes.CHANNEL_MESSAGE(msg.channel.id, msg.id),
json: {
flags: MessageFlags.SUPPRESS_EMBEDS,
},
})
.catch(() => {});
await msg.channel.createMessage({
embeds,
allowedMentions: {