1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 09:56:24 +00:00

Add ignored messages to NoBlockedMessages

This commit is contained in:
jamesbt365 2025-01-06 02:13:10 +00:00
parent 0fd76ab15a
commit ea5a750acb
No known key found for this signature in database
GPG key ID: B375A092448F9102

View file

@ -34,8 +34,8 @@ interface MessageDeleteProps {
export default definePlugin({ export default definePlugin({
name: "NoBlockedMessages", name: "NoBlockedMessages",
description: "Hides all blocked messages from chat completely.", description: "Hides all blocked/ignored messages from chat completely.",
authors: [Devs.rushii, Devs.Samu], authors: [Devs.rushii, Devs.Samu, Devs.jamesbt365],
patches: [ patches: [
{ {
find: "#{intl::BLOCKED_MESSAGES_HIDE}", find: "#{intl::BLOCKED_MESSAGES_HIDE}",
@ -55,7 +55,7 @@ export default definePlugin({
replacement: [ replacement: [
{ {
match: /(?<=function (\i)\((\i)\){)(?=.*MESSAGE_CREATE:\1)/, match: /(?<=function (\i)\((\i)\){)(?=.*MESSAGE_CREATE:\1)/,
replace: (_, _funcName, props) => `if($self.isBlocked(${props}.message))return;` replace: (_, _funcName, props) => `if($self.shouldIgnoreMessage(${props}.message))return;`
} }
] ]
})) }))
@ -67,22 +67,44 @@ export default definePlugin({
default: false, default: false,
restartNeeded: true, restartNeeded: true,
}, },
ignoreIgnoredMessages: {
description: "Additionally apply to 'ignored' users.",
type: OptionType.BOOLEAN,
default: true,
restartNeeded: false,
}, },
isBlocked(message: Message) {
try {
return RelationshipStore.isBlocked(message.author.id);
} catch (e) {
new Logger("NoBlockedMessages").error("Failed to check if user is blocked:", e);
}
}, },
shouldHide(props: MessageDeleteProps) { shouldIgnoreMessage(message: Message) {
try { try {
return props.collapsedReason() === i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")](); if (RelationshipStore.isBlocked(message.author.id)) {
} catch (e) { return true;
console.error(e);
} }
if (this.options.ignoreIgnoredMessages && RelationshipStore.isIgnored(message.author.id)) {
return true;
}
return false;
} catch (e) {
new Logger("NoBlockedMessages").error("Failed to check if user is blocked or ignored:", e);
return false; return false;
} }
},
shouldHide(props: MessageDeleteProps): boolean {
try {
const collapsedReason = props.collapsedReason();
const blockedReason = i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")]();
const ignoredReason = Settings.plugins.NoBlockedMessages.ignoreIgnoredMessages
? i18n.t[runtimeHashMessageKey("IGNORED_MESSAGE_COUNT")]()
: null;
return collapsedReason === blockedReason || collapsedReason === ignoredReason;
} catch (e) {
console.error(e);
return false;
}
}
}); });