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:
parent
0fd76ab15a
commit
ea5a750acb
1 changed files with 31 additions and 9 deletions
|
@ -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) {
|
shouldIgnoreMessage(message: Message) {
|
||||||
try {
|
try {
|
||||||
return RelationshipStore.isBlocked(message.author.id);
|
if (RelationshipStore.isBlocked(message.author.id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (this.options.ignoreIgnoredMessages && RelationshipStore.isIgnored(message.author.id)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
} 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 or ignored:", e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
shouldHide(props: MessageDeleteProps) {
|
shouldHide(props: MessageDeleteProps): boolean {
|
||||||
try {
|
try {
|
||||||
return props.collapsedReason() === i18n.t[runtimeHashMessageKey("BLOCKED_MESSAGE_COUNT")]();
|
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) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue