From 026d39aef2dee2cfd71a31d870e6ecc119e2883a Mon Sep 17 00:00:00 2001 From: thororen1234 <78185467+thororen1234@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:49:35 -0400 Subject: [PATCH] Add back ServerSearch & DeadMembers --- src/equicordplugins/deadMembers/index.tsx | 62 ++++++++++++++++++++ src/equicordplugins/serverSearch/index.tsx | 64 +++++++++++++++++++++ src/equicordplugins/serverSearch/styles.css | 33 +++++++++++ 3 files changed, 159 insertions(+) create mode 100644 src/equicordplugins/deadMembers/index.tsx create mode 100644 src/equicordplugins/serverSearch/index.tsx create mode 100644 src/equicordplugins/serverSearch/styles.css diff --git a/src/equicordplugins/deadMembers/index.tsx b/src/equicordplugins/deadMembers/index.tsx new file mode 100644 index 00000000..d14df454 --- /dev/null +++ b/src/equicordplugins/deadMembers/index.tsx @@ -0,0 +1,62 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { ChannelStore, GuildMemberStore, useStateFromStores } from "@webpack/common"; + +export default definePlugin({ + name: "DeadMembers", + description: "Shows when the sender of a message has left the guild", + authors: [Devs.Kyuuhachi], + + patches: [ + { + find: '.BADGES=1]="BADGES"', + replacement: { + match: /(\i)=\{className:\i.username,style:.*?onContextMenu:\i,children:.*?\};/, + replace: "$&$1.children=$self.wrapMessageAuthor(arguments[0],$1.children);" + } + }, + { + find: "Messages.FORUM_POST_AUTHOR_A11Y_LABEL", + replacement: { + match: /(?<=\}=(\i),\{(user:\i,author:\i)\}=.{0,400}?\(\i\.Fragment,{children:)\i(?=}\),)/, + replace: "$self.wrapForumAuthor({...$1,$2},$&)" + } + }, + ], + + wrapMessageAuthor({ message }, text) { + const channel = ChannelStore.getChannel(message.channel_id); + return message.webhookId + ? text + : ; + }, + + wrapForumAuthor({ channel, user }, text) { + return !user + ? text + : ; + }, +}); + + +function DeadIndicator({ channel, userId, text }) { + const isMember = useStateFromStores( + [GuildMemberStore], + () => GuildMemberStore.isMember(channel?.guild_id, userId), + ); + return channel?.guild_id && !isMember ? {text} : text; +} diff --git a/src/equicordplugins/serverSearch/index.tsx b/src/equicordplugins/serverSearch/index.tsx new file mode 100644 index 00000000..9458abc8 --- /dev/null +++ b/src/equicordplugins/serverSearch/index.tsx @@ -0,0 +1,64 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated, camila314, and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./styles.css"; + +import { addServerListElement, removeServerListElement, ServerListRenderPosition } from "@api/ServerList"; +import ErrorBoundary from "@components/ErrorBoundary"; +import { EquicordDevs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { FluxDispatcher } from "@webpack/common"; +import { Tooltip } from "webpack/common/components"; + +function SearchIcon() { + return ( + + + + ); +} + +export default definePlugin({ + name: "ServerSearch", + authors: [EquicordDevs.camila314], + description: "Navigate your servers better with a quick search button", + + renderButton() { + return + + + {({ onMouseEnter, onMouseLeave }) => ( + + FluxDispatcher.dispatch({ + type: "QUICKSWITCHER_SHOW", + query: "", + queryMode: null + }) + }> + + + )} + + + ; + }, + + start() { + addServerListElement(ServerListRenderPosition.Above, this.renderButton); + }, + + stop() { + removeServerListElement(ServerListRenderPosition.Above, this.renderButton); + } +}); diff --git a/src/equicordplugins/serverSearch/styles.css b/src/equicordplugins/serverSearch/styles.css new file mode 100644 index 00000000..db2e745a --- /dev/null +++ b/src/equicordplugins/serverSearch/styles.css @@ -0,0 +1,33 @@ +#vc-searchbutton-container { + width: 100%; + display: flex; + align-items: center; + justify-content: center; + margin-bottom: 8px; +} + +#vc-searchbutton { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + background-color: var(--background-primary); + height: 48px; + width: 48px; + border-radius: 100%; + transition: border-radius 0.15s ease-out, background-color 0.15s ease-out; +} + +#vc-searchbutton-icon { + color: var(--text-normal); +} + +#vc-searchbutton:hover { + border-radius: 34%; + background-color: var(--green-360); + cursor: pointer; +} + +#vc-searchbutton:hover #vc-searchbutton-icon { + color: var(--white-500); +}