setup the thing
This commit is contained in:
commit
31c26cde88
2 changed files with 61 additions and 0 deletions
23
README.md
Normal file
23
README.md
Normal file
|
@ -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.
|
38
index.tsx
Normal file
38
index.tsx
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in a new issue