fedimbed+codePreviews: fix embed suppression not working due to oversight in oceanic
This commit is contained in:
parent
a15962c110
commit
13b6357640
2 changed files with 31 additions and 4 deletions
|
@ -106,7 +106,18 @@ events.add("messageCreate", "codePreviews", async function (msg) {
|
||||||
if (out.length > 2000) return;
|
if (out.length > 2000) return;
|
||||||
|
|
||||||
if (out !== "") {
|
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({
|
await msg.channel.createMessage({
|
||||||
content: out,
|
content: out,
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
const {MessageFlags, Routes} = require("oceanic.js");
|
||||||
|
|
||||||
const events = require("../lib/events.js");
|
const events = require("../lib/events.js");
|
||||||
const logger = require("../lib/logger.js");
|
const logger = require("../lib/logger.js");
|
||||||
const {hasFlag} = require("../lib/guildSettings.js");
|
const {hasFlag} = require("../lib/guildSettings.js");
|
||||||
|
@ -68,7 +70,7 @@ async function processUrl(msg, url) {
|
||||||
.replace(/^(.)/, (_, c) => c.toUpperCase());
|
.replace(/^(.)/, (_, c) => c.toUpperCase());
|
||||||
|
|
||||||
const attachments = [];
|
const attachments = [];
|
||||||
let content, cw, author;
|
let content, cw, author, timestamp;
|
||||||
|
|
||||||
// Fetch post
|
// Fetch post
|
||||||
const rawPostData = await fetch(url, {
|
const rawPostData = await fetch(url, {
|
||||||
|
@ -149,7 +151,10 @@ async function processUrl(msg, url) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
content = postData.content;
|
content = postData.content;
|
||||||
|
@ -260,7 +265,18 @@ async function processUrl(msg, url) {
|
||||||
embeds.push(embed);
|
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({
|
await msg.channel.createMessage({
|
||||||
embeds,
|
embeds,
|
||||||
allowedMentions: {
|
allowedMentions: {
|
||||||
|
|
Loading…
Reference in a new issue