commit 88e8f086f291e2e5a5b7d8f53c5b17e17b371bc3 Author: nin0dev Date: Fri Nov 1 10:53:33 2024 -0400 Initial commit diff --git a/index.tsx b/index.tsx new file mode 100644 index 0000000..f76f205 --- /dev/null +++ b/index.tsx @@ -0,0 +1,36 @@ +import { Notices } from "@api/index"; +import { addAccessory } from "@api/MessageAccessories"; +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { Button, ChannelStore, Forms } from "@webpack/common"; +import { Message } from "discord-types/general"; + +const WHITELISTED_SHARE_CHANNELS = ["1256395889354997771", "1032200195582197831"]; +const CLONE_LINK_REGEX = /(https:\/\/(?:github\.com|git\.nin0\.dev|codeberg\.org)\/[a-zA-Z0-9]+\/[a-zA-Z0-9]+(?:\.git)?(?:\/)?)/; + +function UserpluginInstallButton({ props }: any) { + const message: Message = props.message; + if (!WHITELISTED_SHARE_CHANNELS.includes(ChannelStore.getChannel(message.channel_id).parent_id) && !WHITELISTED_SHARE_CHANNELS.includes(message.channel_id)) + return; + const gitLink = (props.message.content as string).match(CLONE_LINK_REGEX); + if (!gitLink) return; + return ; +} + +export default definePlugin({ + name: "UserpluginInstaller", + description: "Install userplugins with a simple button click", + authors: [Devs.nin0dev], + start() { + addAccessory("userpluginInstallButton", (props: Record) => ( + + ), 4); + } +});