- {edit.content}
+ {Parser.parse(edit.content)}
addDeleteStyleClass()
+ },
+ ignoreBots: {
+ type: OptionType.BOOLEAN,
+ description: "Whether to ignore messages by bots",
+ default: false
+ },
+ ignoreSelf: {
+ type: OptionType.BOOLEAN,
+ description: "Whether to ignore messages by yourself",
+ default: false
}
},
+ handleDelete(cache: any, data: { ids: string[], id: string; }, isBulk: boolean) {
+ try {
+ if (cache == null || (!isBulk && !cache.has(data.id))) return cache;
+
+ const { ignoreBots, ignoreSelf } = Settings.plugins.MessageLogger;
+ const myId = UserStore.getCurrentUser().id;
+
+ function mutate(id: string) {
+ const msg = cache.get(id);
+ if (!msg) return;
+
+ const EPHEMERAL = 64;
+ const shouldIgnore = (msg.flags & EPHEMERAL) === EPHEMERAL ||
+ ignoreBots && msg.author?.bot ||
+ ignoreSelf && msg.author?.id === myId;
+
+ if (shouldIgnore) {
+ cache = cache.remove(id);
+ } else {
+ cache = cache.update(id, m => m
+ .set("deleted", true)
+ .set("attachments", m.attachments.map(a => (a.deleted = true, a))));
+ }
+ }
+
+ if (isBulk) {
+ data.ids.forEach(mutate);
+ } else {
+ mutate(data.id);
+ }
+ } catch (e) {
+ new Logger("MessageLogger").error("Error during handleDelete", e);
+ }
+ return cache;
+ },
+
// Based on canary 9ab8626bcebceaea6da570b9c586172d02b9c996
patches: [
{
@@ -139,7 +191,7 @@ export default definePlugin({
replace:
"MESSAGE_DELETE:function($1){" +
" var cache = $2getOrCreate($1.channelId);" +
- " cache = cache.update($1.id,m=>m.set('deleted', true).set('attachments', m.attachments.map(a => (a.deleted = true, a))));" +
+ " cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, false);" +
" $2commit(cache);" +
"},"
},
@@ -149,7 +201,7 @@ export default definePlugin({
replace:
"MESSAGE_DELETE_BULK:function($1){" +
" var cache = $2getOrCreate($1.channelId);" +
- " cache = $1.ids.reduce((pv,cv) => pv.update(cv, m => m.set('deleted', true).set('attachments', m.attachments.map(a => (a.deleted = true, a)))), cache);" +
+ " cache = Vencord.Plugins.plugins.MessageLogger.handleDelete(cache, $1, true);" +
" $2commit(cache);" +
"},"
},
diff --git a/src/utils/logger.ts b/src/utils/Logger.ts
similarity index 100%
rename from src/utils/logger.ts
rename to src/utils/Logger.ts
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 22504ce2c..41e1597a1 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -21,9 +21,10 @@ export * as Constants from "./constants";
export * from "./debounce";
export * as Discord from "./discord";
export { default as IpcEvents } from "./IpcEvents";
-export { default as Logger } from "./logger";
+export { default as Logger } from "./Logger";
export * from "./misc";
export * as Modals from "./modal";
export * from "./onceDefined";
export * from "./proxyLazy";
export * from "./Queue";
+
diff --git a/src/utils/updater.ts b/src/utils/updater.ts
index ea2319f9d..2ea4953fc 100644
--- a/src/utils/updater.ts
+++ b/src/utils/updater.ts
@@ -19,7 +19,7 @@
import gitHash from "~git-hash";
import IpcEvents from "./IpcEvents";
-import Logger from "./logger";
+import Logger from "./Logger";
import { IpcRes } from "./types";
export const UpdateLogger = new Logger("Updater", "white");
diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts
index 40a16a62b..e17ddfcfc 100644
--- a/src/webpack/patchWebpack.ts
+++ b/src/webpack/patchWebpack.ts
@@ -17,7 +17,7 @@
*/
import { WEBPACK_CHUNK } from "../utils/constants";
-import Logger from "../utils/logger";
+import Logger from "../utils/Logger";
import { _initWebpack } from ".";
let webpackChunk: any[];
diff --git a/src/webpack/webpack.ts b/src/webpack/webpack.ts
index b78afd084..df3213272 100644
--- a/src/webpack/webpack.ts
+++ b/src/webpack/webpack.ts
@@ -19,7 +19,7 @@
import type { WebpackInstance } from "discord-types/other";
import { traceFunction } from "../debug/Tracer";
-import Logger from "../utils/logger";
+import Logger from "../utils/Logger";
import { proxyLazy } from "../utils/proxyLazy";
const logger = new Logger("Webpack");