mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
feat(Plugin): Filter bot mentions
This commit is contained in:
parent
f27361f017
commit
cdc2055e78
2 changed files with 74 additions and 0 deletions
5
src/plugins/filterBotMentions/README.md
Normal file
5
src/plugins/filterBotMentions/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Filter Bot Mentions
|
||||
Allows you to filter bot mentions in recent mentions panel.
|
||||
|
||||
# Usage
|
||||
You can include/exclude bot mentions via the checkbox in recent mentions panel, or the plugin settings.
|
69
src/plugins/filterBotMentions/index.tsx
Normal file
69
src/plugins/filterBotMentions/index.tsx
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import { getCurrentGuild } from "@utils/discord";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByProps } from "@webpack";
|
||||
import { FluxDispatcher } from "@webpack/common";
|
||||
|
||||
const settings = definePluginSettings({
|
||||
toggle: {
|
||||
type: OptionType.BOOLEAN,
|
||||
description: "Filter out mentions by bots",
|
||||
default: false,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
export default definePlugin({
|
||||
name: "Filter Bot Mentions",
|
||||
description: "Filter mentions by bots",
|
||||
authors: [Devs.Taran],
|
||||
version: "1.0.0",
|
||||
|
||||
patches: [
|
||||
{
|
||||
find: "type:\"LOAD_RECENT_MENTIONS_SUCCESS\"",
|
||||
replacement: {
|
||||
match: /dispatch\(\{type:"LOAD_RECENT_MENTIONS_SUCCESS",messages:(\i)/,
|
||||
replace: "$&.filter(function (message) {if (!message.author.bot){return true} else {return $self.settings.store.toggle}})"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "analyticsName:\"Recent Mentions\"",
|
||||
replacement: {
|
||||
match: /channel:\i,messages:\i/,
|
||||
replace: "$&?.filter(function (message) {if (!message.author.bot){return true} else {return $self.settings.store.toggle}})"
|
||||
}
|
||||
},
|
||||
{
|
||||
find: "mentions-filter",
|
||||
replacement: {
|
||||
match: /children:\[\(0,(\i)\.jsx\)\((\i).{0,200}(\i)\.(\i)\.setGuildFilter.{0,100}checked:(\i).{0,200}checked:(\i).{0,300}checked:(.{0,30})\}\)\]/,
|
||||
replace: "$&.concat([(0,$1.jsx)($2.MenuCheckboxItem, {id:\"Bots\", label:\"Include mentions by bots\", action: function() {$self.toggleBotMentions();$self.reloadMentions($5, $6, $7)}, checked: $self.settings.store.toggle})])"
|
||||
}
|
||||
}
|
||||
|
||||
],
|
||||
settings,
|
||||
reloadMentions(everyone, role, all_servers) {
|
||||
FluxDispatcher.dispatch({ type: "CLEAR_MENTIONS" });
|
||||
if (all_servers === false) {
|
||||
all_servers = getCurrentGuild()?.id;
|
||||
} else {
|
||||
all_servers = null;
|
||||
}
|
||||
|
||||
findByProps("fetchRecentMentions").fetchRecentMentions(null, null, all_servers, role, everyone);
|
||||
|
||||
},
|
||||
toggleBotMentions() {
|
||||
this.settings.store.toggle = !this.settings.store.toggle;
|
||||
}
|
||||
|
||||
});
|
Loading…
Reference in a new issue