/* * Vencord, a Discord client mod * Copyright (c) 2024 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ import { ChatBarButton } from "@api/ChatButtons"; import { definePluginSettings } from "@api/Settings"; import { EquicordDevs } from "@utils/constants"; import definePlugin, { OptionType, StartAt } from "@utils/types"; import { useMemo, useState } from "@webpack/common"; import { MouseEventHandler } from "react"; let hidechatbuttonsopen: boolean | undefined; const settings = definePluginSettings({ Color: { type: OptionType.BOOLEAN, description: "Color it red on open", // something extra default: false, }, Open: { type: OptionType.BOOLEAN, description: "opened by default", default: false, onChange: (store: { open: boolean; }) => { hidechatbuttonsopen = store.open; } }, }); function HideToggleButton(props: { open: boolean | undefined, onClick: MouseEventHandler; }) { return ( {props.open ? <> : } ); } interface ButtonReactNode { props?: { disabled?: boolean; }; } function buttonsInner(buttons: ButtonReactNode[]) { if (buttons.every(x => x.props?.disabled === true)) { return null; } const [open, setOpen] = useState(hidechatbuttonsopen); useMemo(() => { hidechatbuttonsopen = open; }, [open]); const buttonList = (
{open ? buttons.map(b => <>{b}) : null} setOpen(!open)} open={open}>
); buttons = [buttonList]; return buttons; } export default definePlugin({ name: "hideChatButtons", description: "able to hide the chat buttons", settings: settings, authors: [EquicordDevs.iamme], patches: [ { find: '"sticker")', replacement: { match: /(.buttons,children:)(\i)\}/, replace: "$1$self.buttonsInner($2)}" } } ], startAt: StartAt.Init, buttonsInner: buttonsInner, start: async () => { hidechatbuttonsopen = settings.store.Open; } });