mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-18 02:47:03 -04:00
Updates
This commit is contained in:
commit
69d28600ac
4 changed files with 43 additions and 4 deletions
|
@ -21,6 +21,7 @@ import { Devs } from "@utils/constants";
|
|||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { MessageStore } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
|
||||
const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
||||
|
@ -28,7 +29,7 @@ const RelationshipStore = findByPropsLazy("getRelationships", "isBlocked");
|
|||
export default definePlugin({
|
||||
name: "NoBlockedMessages",
|
||||
description: "Hides all blocked messages from chat completely.",
|
||||
authors: [Devs.rushii, Devs.Samu],
|
||||
authors: [Devs.rushii, Devs.Samu, Devs.F53],
|
||||
patches: [
|
||||
{
|
||||
find: "Messages.BLOCKED_MESSAGES_HIDE",
|
||||
|
@ -48,10 +49,17 @@ export default definePlugin({
|
|||
replacement: [
|
||||
{
|
||||
match: /(?<=MESSAGE_CREATE:function\((\i)\){)/,
|
||||
replace: (_, props) => `if($self.isBlocked(${props}.message))return;`
|
||||
replace: (_, props) => `if($self.isBlocked(${props}.message)||$self.isReplyToBlocked(${props}.message))return;`
|
||||
}
|
||||
]
|
||||
}))
|
||||
})),
|
||||
{
|
||||
find: ".messageListItem",
|
||||
replacement: {
|
||||
match: /(?<=\i=)(?=\(0,(\i)\.jsx)/,
|
||||
replace: "!$self.isReplyToBlocked(arguments[0].message)&&"
|
||||
}
|
||||
}
|
||||
],
|
||||
options: {
|
||||
ignoreBlockedMessages: {
|
||||
|
@ -60,9 +68,26 @@ export default definePlugin({
|
|||
default: false,
|
||||
restartNeeded: true,
|
||||
},
|
||||
hideRepliesToBlockedMessages: {
|
||||
description: "Hide replies to messages made by users you've blocked",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: false,
|
||||
restartNeeded: false,
|
||||
}
|
||||
},
|
||||
|
||||
isBlocked(message: Message) {
|
||||
isReplyToBlocked(message: Message) {
|
||||
if (!Settings.plugins.NoBlockedMessages.hideRepliesToBlockedMessages)
|
||||
return false;
|
||||
|
||||
const { messageReference } = message;
|
||||
if (!messageReference) return false;
|
||||
const replyMessage = MessageStore.getMessage(messageReference.channel_id, messageReference.message_id);
|
||||
return this.isBlocked(replyMessage);
|
||||
},
|
||||
|
||||
isBlocked(message: Message | undefined) {
|
||||
if (!message) return false;
|
||||
try {
|
||||
return RelationshipStore.isBlocked(message.author.id);
|
||||
} catch (e) {
|
||||
|
|
|
@ -52,6 +52,11 @@ export const useDrag = findByCodeLazy("useDrag::spec.begin was deprecated");
|
|||
// you cant make a better finder i love that they remove display names sm
|
||||
export const useDrop = findByCodeLazy(".options);return", ".collect,");
|
||||
|
||||
export const { match, P }: Pick<typeof import("ts-pattern"), "match" | "P"> = mapMangledModuleLazy("@ts-pattern/matcher", {
|
||||
match: filters.byCode("return new"),
|
||||
P: filters.byProps("when")
|
||||
});
|
||||
|
||||
export const lodash: typeof import("lodash") = findByPropsLazy("debounce", "cloneDeep");
|
||||
|
||||
export const i18n: t.i18n = findLazy(m => m.Messages?.["en-US"]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue