NoBlockedMessages: Fix conflict with MessageLogger (#2921)

This commit is contained in:
sadan4 2024-10-04 05:29:59 -04:00 committed by GitHub
parent 91a32e22de
commit 1e01f85217
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,6 +25,12 @@ import { Message } from "discord-types/general";
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked"); const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
interface MessageDeleteProps {
collapsedReason: {
message: string;
};
}
export default definePlugin({ export default definePlugin({
name: "NoBlockedMessages", name: "NoBlockedMessages",
description: "Hides all blocked messages from chat completely.", description: "Hides all blocked messages from chat completely.",
@ -35,7 +41,7 @@ export default definePlugin({
replacement: [ replacement: [
{ {
match: /let\{[^}]*collapsedReason[^}]*\}/, match: /let\{[^}]*collapsedReason[^}]*\}/,
replace: "return null;$&" replace: "if($self.shouldHide(arguments[0]))return null;$&"
} }
] ]
}, },
@ -68,5 +74,9 @@ export default definePlugin({
} catch (e) { } catch (e) {
new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e); new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e);
} }
},
shouldHide(props: MessageDeleteProps) {
return !props?.collapsedReason?.message.includes("deleted");
} }
}); });