mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Compare commits
19 commits
ead6195434
...
6fb63116b9
Author | SHA1 | Date | |
---|---|---|---|
|
6fb63116b9 | ||
|
c7e5295da0 | ||
|
513eccb70a | ||
|
11dd4cf3b0 | ||
|
1755c2cf6f | ||
|
4d9acac992 | ||
|
24fa55bbbe | ||
|
3bf235d115 | ||
|
6b952c24be | ||
|
ecfc09ac3f | ||
|
608fdd4f96 | ||
|
2b887fda18 | ||
|
18c2b7d730 | ||
|
35bc98b2b5 | ||
|
73a6d43840 | ||
|
cd2568cfcd | ||
|
bc655d673b | ||
|
e7a233f1d3 | ||
|
cdc2055e78 |
7 changed files with 188 additions and 81 deletions
13
src/plugins/filterBotMentions/README.md
Normal file
13
src/plugins/filterBotMentions/README.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# FilterBotMentions
|
||||||
|
Allows you to filter bot mentions in recent mentions panel.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
You can include/exclude mentions by bots in the box either using the checkbox in recent mentions panel, or in the plugin settings.
|
||||||
|
|
||||||
|
Include mentions by bots:
|
||||||
|
![image](https://github.com/user-attachments/assets/a80a41fc-9bae-4612-a23a-b1894e0f8fd2)
|
||||||
|
|
||||||
|
Excluded mentions by bots:
|
||||||
|
![image](https://github.com/user-attachments/assets/fdf973eb-23ef-4101-b4de-e3fb6663f41b)
|
||||||
|
|
||||||
|
|
84
src/plugins/filterBotMentions/index.tsx
Normal file
84
src/plugins/filterBotMentions/index.tsx
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
/*
|
||||||
|
* 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 { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||||
|
import { Menu } from "@webpack/common";
|
||||||
|
import { Message } from "discord-types/general";
|
||||||
|
|
||||||
|
|
||||||
|
const settings = definePluginSettings({
|
||||||
|
toggle: {
|
||||||
|
type: OptionType.BOOLEAN,
|
||||||
|
description: "Include mentions by bots in inbox",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
type RecentMentionsStore = { guildFilter: string, roleFilter: boolean, everyoneFilter: boolean; };
|
||||||
|
type fetchRecentMentionsType = (before: BigInt | null, limit: Number | null, all_servers: string | null | undefined, role: boolean, everyone: boolean,) => void;
|
||||||
|
|
||||||
|
const { fetchRecentMentions } = findByPropsLazy("fetchRecentMentions") as { fetchRecentMentions: fetchRecentMentionsType; };
|
||||||
|
const recentMentionsStore = findStoreLazy("RecentMentionsStore") as RecentMentionsStore;
|
||||||
|
|
||||||
|
|
||||||
|
export default definePlugin({
|
||||||
|
name: "FilterBotMentions",
|
||||||
|
description: "Filter mentions by bots in inbox",
|
||||||
|
authors: [Devs.Taran],
|
||||||
|
|
||||||
|
patches: [
|
||||||
|
{
|
||||||
|
find: "get lastLoaded",
|
||||||
|
replacement: {
|
||||||
|
match: /getMentions.{0,30}\?\i/,
|
||||||
|
replace: "$&.filter($self.filterMessages)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: "mentions-filter",
|
||||||
|
replacement: {
|
||||||
|
match: /children:\[\(0,\i\.jsx\).{0,600}\}\)\]/,
|
||||||
|
replace: "$&.concat($self.patchMenu())"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
],
|
||||||
|
settings,
|
||||||
|
reloadMentions(): void {
|
||||||
|
const all_servers: boolean = recentMentionsStore.guildFilter === "ALL_SERVERS";
|
||||||
|
const { roleFilter: role, everyoneFilter: everyone } = recentMentionsStore;
|
||||||
|
const serverToFilter: string | undefined | null = all_servers ? null : getCurrentGuild()?.id;
|
||||||
|
fetchRecentMentions(null, null, serverToFilter, role, everyone);
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleBotMentions(): void {
|
||||||
|
settings.store.toggle = !settings.store.toggle;
|
||||||
|
},
|
||||||
|
|
||||||
|
filterMessages(message: Message): boolean {
|
||||||
|
return !message.author.bot || settings.store.toggle;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
patchMenu() {
|
||||||
|
return (
|
||||||
|
<Menu.MenuCheckboxItem
|
||||||
|
id="Bots"
|
||||||
|
label="Include mentions by bots"
|
||||||
|
action={() => {
|
||||||
|
this.toggleBotMentions();
|
||||||
|
this.reloadMentions();
|
||||||
|
}}
|
||||||
|
checked={settings.store.toggle}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
5
src/plugins/fullSearchContext/README.md
Normal file
5
src/plugins/fullSearchContext/README.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# FullSearchContext
|
||||||
|
|
||||||
|
Makes the message context menu in message search results have all options you'd expect.
|
||||||
|
|
||||||
|
![](https://github.com/user-attachments/assets/472d1327-3935-44c7-b7c4-0978b5348550)
|
82
src/plugins/fullSearchContext/index.tsx
Normal file
82
src/plugins/fullSearchContext/index.tsx
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a modification for Discord's desktop app
|
||||||
|
* Copyright (c) 2023 Vendicated and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { migratePluginSettings } from "@api/Settings";
|
||||||
|
import { Devs } from "@utils/constants";
|
||||||
|
import definePlugin from "@utils/types";
|
||||||
|
import { findByPropsLazy } from "@webpack";
|
||||||
|
import { ChannelStore, ContextMenuApi, i18n, UserStore } from "@webpack/common";
|
||||||
|
import { Message } from "discord-types/general";
|
||||||
|
import type { MouseEvent } from "react";
|
||||||
|
|
||||||
|
const { useMessageMenu } = findByPropsLazy("useMessageMenu");
|
||||||
|
|
||||||
|
function MessageMenu({ message, channel, onHeightUpdate }) {
|
||||||
|
const canReport = message.author &&
|
||||||
|
!(message.author.id === UserStore.getCurrentUser().id || message.author.system);
|
||||||
|
|
||||||
|
return useMessageMenu({
|
||||||
|
navId: "message-actions",
|
||||||
|
ariaLabel: i18n.Messages.MESSAGE_UTILITIES_A11Y_LABEL,
|
||||||
|
|
||||||
|
message,
|
||||||
|
channel,
|
||||||
|
canReport,
|
||||||
|
onHeightUpdate,
|
||||||
|
onClose: () => ContextMenuApi.closeContextMenu(),
|
||||||
|
|
||||||
|
textSelection: "",
|
||||||
|
favoriteableType: null,
|
||||||
|
favoriteableId: null,
|
||||||
|
favoriteableName: null,
|
||||||
|
itemHref: void 0,
|
||||||
|
itemSrc: void 0,
|
||||||
|
itemSafeSrc: void 0,
|
||||||
|
itemTextContent: void 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
migratePluginSettings("FullSearchContext", "SearchReply");
|
||||||
|
export default definePlugin({
|
||||||
|
name: "FullSearchContext",
|
||||||
|
description: "Makes the message context menu in message search results have all options you'd expect",
|
||||||
|
authors: [Devs.Ven, Devs.Aria],
|
||||||
|
|
||||||
|
patches: [{
|
||||||
|
find: "onClick:this.handleMessageClick,",
|
||||||
|
replacement: {
|
||||||
|
match: /this(?=\.handleContextMenu\(\i,\i\))/,
|
||||||
|
replace: "$self"
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
|
||||||
|
handleContextMenu(event: MouseEvent, message: Message) {
|
||||||
|
const channel = ChannelStore.getChannel(message.channel_id);
|
||||||
|
if (!channel) return;
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
ContextMenuApi.openContextMenu(event, contextMenuProps =>
|
||||||
|
<MessageMenu
|
||||||
|
message={message}
|
||||||
|
channel={channel}
|
||||||
|
onHeightUpdate={contextMenuProps.onHeightUpdate}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,6 +0,0 @@
|
||||||
# SearchReply
|
|
||||||
|
|
||||||
Adds a reply button to search results.
|
|
||||||
|
|
||||||
![the plugin in action](https://github.com/Vendicated/Vencord/assets/45497981/07e741d3-0f97-4e5c-82b0-80712ecf2cbb)
|
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* Vencord, a modification for Discord's desktop app
|
|
||||||
* Copyright (c) 2023 Vendicated and contributors
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
|
||||||
import { ReplyIcon } from "@components/Icons";
|
|
||||||
import { Devs } from "@utils/constants";
|
|
||||||
import definePlugin from "@utils/types";
|
|
||||||
import { findByCodeLazy } from "@webpack";
|
|
||||||
import { ChannelStore, i18n, Menu, PermissionsBits, PermissionStore, SelectedChannelStore } from "@webpack/common";
|
|
||||||
import { Message } from "discord-types/general";
|
|
||||||
|
|
||||||
|
|
||||||
const replyToMessage = findByCodeLazy(".TEXTAREA_FOCUS)", "showMentionToggle:");
|
|
||||||
|
|
||||||
const messageContextMenuPatch: NavContextMenuPatchCallback = (children, { message }: { message: Message; }) => {
|
|
||||||
// make sure the message is in the selected channel
|
|
||||||
if (SelectedChannelStore.getChannelId() !== message.channel_id) return;
|
|
||||||
const channel = ChannelStore.getChannel(message?.channel_id);
|
|
||||||
if (!channel) return;
|
|
||||||
if (channel.guild_id && !PermissionStore.can(PermissionsBits.SEND_MESSAGES, channel)) return;
|
|
||||||
|
|
||||||
// dms and group chats
|
|
||||||
const dmGroup = findGroupChildrenByChildId("pin", children);
|
|
||||||
if (dmGroup && !dmGroup.some(child => child?.props?.id === "reply")) {
|
|
||||||
const pinIndex = dmGroup.findIndex(c => c?.props.id === "pin");
|
|
||||||
dmGroup.splice(pinIndex + 1, 0, (
|
|
||||||
<Menu.MenuItem
|
|
||||||
id="reply"
|
|
||||||
label={i18n.Messages.MESSAGE_ACTION_REPLY}
|
|
||||||
icon={ReplyIcon}
|
|
||||||
action={(e: React.MouseEvent) => replyToMessage(channel, message, e)}
|
|
||||||
/>
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// servers
|
|
||||||
const serverGroup = findGroupChildrenByChildId("mark-unread", children);
|
|
||||||
if (serverGroup && !serverGroup.some(child => child?.props?.id === "reply")) {
|
|
||||||
serverGroup.unshift((
|
|
||||||
<Menu.MenuItem
|
|
||||||
id="reply"
|
|
||||||
label={i18n.Messages.MESSAGE_ACTION_REPLY}
|
|
||||||
icon={ReplyIcon}
|
|
||||||
action={(e: React.MouseEvent) => replyToMessage(channel, message, e)}
|
|
||||||
/>
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export default definePlugin({
|
|
||||||
name: "SearchReply",
|
|
||||||
description: "Adds a reply button to search results",
|
|
||||||
authors: [Devs.Aria],
|
|
||||||
contextMenus: {
|
|
||||||
"message": messageContextMenuPatch
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -575,6 +575,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
||||||
name: "RamziAH",
|
name: "RamziAH",
|
||||||
id: 1279957227612147747n,
|
id: 1279957227612147747n,
|
||||||
},
|
},
|
||||||
|
Taran: {
|
||||||
|
name: "Taran",
|
||||||
|
id: 482951588055351306n
|
||||||
|
},
|
||||||
} satisfies Record<string, Dev>);
|
} satisfies Record<string, Dev>);
|
||||||
|
|
||||||
// iife so #__PURE__ works correctly
|
// iife so #__PURE__ works correctly
|
||||||
|
|
Loading…
Reference in a new issue