commit 31c26cde881bd8bee7b5948d46df71312de18726 Author: Sqaaakoi Date: Sat Dec 28 20:24:40 2024 +1300 setup the thing diff --git a/README.md b/README.md new file mode 100644 index 0000000..77493d8 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# ShyTyping + +Prevents you from accidentally revealing that you're lurking in a channel + +Works with SilentTyping + +## What it does + +Only allows the typing start event listener to be called when at least one the following conditions are met + +- You are typing in the your current voice channel +- There is at least one message in the current channel that meets all of the following requirements + - Sent by yourself + - Not deleted (MessageLogger) + - Sent within the past 5 minutes + +## Installation + +### See https://docs.vencord.dev/installing/custom-plugins/ for setting up custom plugins +Once you have setup the environment for custom plugins, clone into the `src/userplugins` folder. + +> [!WARNING] +> Do not ask for support regarding installation, including in Vencord's support channel, my DMs, repository issues, or anywhere this plugin has been published, as you won't recieve help. Follow the guide linked above. diff --git a/index.tsx b/index.tsx new file mode 100644 index 0000000..eacb1c9 --- /dev/null +++ b/index.tsx @@ -0,0 +1,38 @@ +import { Devs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { MessageStore, SelectedChannelStore, UserStore } from "@webpack/common"; +import { Message } from "discord-types/general"; + +export default definePlugin({ + name: "ShyTyping", + description: "Prevents you from accidentally revealing that you're lurking in a channel", + authors: [Devs.Sqaaakoi], + + patches: [ + { + find: '"TypingStore"', + replacement: { + match: /(TYPING_START_LOCAL:)(\i)/, + replace: "$1$self.wrap($2)" + } + } + ], + + wrap(startTyping: ({ channelId }: { channelId: string; }) => void) { + return (e: { channelId: string; }) => { + return this.shouldStartTyping(e.channelId) && startTyping(e); + }; + }, + + shouldStartTyping(channelId: string): boolean { + if (SelectedChannelStore.getVoiceChannelId() === channelId) return true; + const meId = UserStore.getCurrentUser().id; + const threshold = Date.now() - (5 * 60 * 1000); + // discord-types and the MessageStore types are so wrong and cursed + if ((MessageStore.getMessages(channelId)._array as Message[]).filter(m => m.author.id === meId && !(m as any)?.deleted).some(m => +m.timestamp > threshold)) return true; + + + + return false; + } +});