Initial commit: autoMover, friendsCheck, watchCord plugins and README

This commit is contained in:
X4Lo committed 2026-11-11 17:41:39 +00:00
commit f06f2f493b
11 files changed
+3799

No files matched your search

+445
View File
@@ -0,0 +1,445 @@
# WatchCord
A comprehensive Vencord plugin for monitoring and logging Discord user activity, including voice channel changes and online status updates.
## 📋 Features
### Core Functionality
- **Voice Activity Tracking**: Monitor when specific users join, leave, or switch voice channels
- **Channel Members Logging**: Automatically logs existing users in a channel when a watched user joins
- **Associated Activity Tracking**: Logs when other users join or leave a watched user's current voice channel
- **Status Change Tracking**: Track when users change their online status (Online, Idle, DND, Offline, Invisible)
- **Message Watching**: Log when a watched user sends a message (works in servers and DMs)
- **Typing Watching**: Log when a watched user starts typing ("`User` started typing in `#channel`")
- **Per-User Configuration**: Customize tracking settings individually for each watched user
- **Server-Specific Tracking**: Watch users globally or only in specific servers
### Notification Options
- **Desktop Notifications**: Get native desktop notifications for tracked events
- **Sound Alerts**: Optional notification sounds for voice and status changes
- **Discord Webhooks**: Send activity logs (voice, status, messages, typing) to a Discord webhook for external monitoring
- **In-App Logs Viewer**: Built-in interface to view and filter activity logs
### Data Management
- **Persistent Logging**: All events are saved to a text file (`watchcord-logs.txt`)
- **In-Memory Cache**: Fast access to recent logs (last 500 entries)
- **Log Filtering**: Filter logs by type (Voice, Status, or All)
- **Easy Export**: Direct access to log file via "Open Log File" button
## 🚀 Installation
1. Ensure you have [Vencord](https://vencord.dev/) installed
2. Copy the `watchCord` folder to your Vencord `userPlugins` directory:
```
src/userPlugins/watchCord/
├── index.tsx
├── native.ts
└── README.md
```
3. Rebuild Vencord or restart Discord
4. Enable the plugin in Settings → Vencord → Plugins → WatchCord
## ⚙️ Configuration
### Plugin Settings
Access settings via: **Settings → Vencord → Plugins → WatchCord**
#### 1. Webhook URL (Optional)
- **Description**: Discord webhook URL for remote logging
- **Format**: `https://discord.com/api/webhooks/...`
- **Usage**: Leave empty to disable webhook notifications
- **Example**: Logs will be sent as messages to the specified webhook
#### 2. Enable Notifications
- **Description**: Show native desktop notifications for tracked events
- **Default**: Enabled
- **Note**: Requires notification permissions in your browser/client
#### 3. Debug Mode
- **Description**: Log verbose debug information to the DevTools console
- **Default**: Disabled
- **Usage**: Enable it, then open DevTools (Ctrl+Shift+I) → Console and filter by `WatchCord` to see a full trace of the message/typing pipeline (raw events, skip decisions, watch list, and the reason a match did or didn't happen)
- **Note**: `TYPING_START` fires for everyone typing in channels you can see, so this can be noisy — turn it off when done
### Watch List Manager
Add users to monitor with granular control:
#### Adding a User
1. **User ID**: Discord user ID (right-click user → Copy User ID)
2. **Server**: Choose specific server or "All Servers (*)"
3. **Tracking Options**:
- ✅ **Watch Voice**: Track voice channel activity
- ✅ **Watch Status**: Track online status changes
- 💬 **Watch Messages**: Log messages sent by the user
- ⌨️ **Watch Typing**: Log when the user starts typing
- 🔊 **Voice Sound**: Play sound on voice activity
- 🔊 **Status Sound**: Play sound on status changes
4. Click **Add Entry**
> 💡 Existing entries can be toggled inline: each entry in the watch list shows its own checkboxes, so you can enable/disable **Messages** or **Typing** (or any other flag) without removing and re-adding the user.
#### Watch List Display
Each entry shows:
- **User**: Username and User ID
- **Server**: Server name or "All Servers"
- **Active Features**: Icons indicating enabled tracking options
- **Remove Button**: Delete the watch entry
### Logs Viewer
View and manage activity logs:
#### Features
- **Filter Logs**: View All, Voice Only, Status Only, Messages Only, or Typing Only
- **Auto-Refresh**: Logs update every second
- **Color Coding**:
- 🟢 Green: Voice activity
- 🟡 Yellow: Status changes
- 🔵 Blue: Messages
- 🟣 Purple: Typing
- **Buttons**:
- **Open Log File**: Open `watchcord-logs.txt` in your default text editor
- **Open Full Status Changes**: Open `watchcord-full-status-changes.json` to view complete status change objects
- **Clear Logs**: Delete all logs (both in-memory and file)
- **Clear Status Changes**: Delete all full status change records
## 📊 Log Format
### Log Entry Structure
```
[MM/DD/YYYY, HH:MM:SS AM/PM] [TYPE] Message
```
### Log Types
#### Voice Activity - Watched Users
```
[2/11/2026, 3:45:12 PM] [VOICE] <@123456789>(Username-123456789) joined General(987654321) in ServerName(111222333)
└─ Existing users in channel: Alice(111111111), Bob(222222222), Charlie(333333333)
[2/11/2026, 3:47:30 PM] [VOICE] <@123456789>(Username-123456789) left General(987654321) in ServerName(111222333)
```
**Note**: When a watched user joins a voice channel, the plugin logs all existing users in that channel. If the channel is empty, it logs "Empty channel".
#### Voice Activity - Associated Users
```
[2/11/2026, 3:50:00 PM] [VOICE] <@444444444>(David-444444444) joined <@123456789>(Username)'s channel General(987654321) in ServerName(111222333)
[2/11/2026, 3:55:00 PM] [VOICE] <@444444444>(David-444444444) left <@123456789>(Username)'s channel General(987654321) in ServerName(111222333)
```
**Note**: When someone joins or leaves a channel where a watched user is currently present, those events are also logged.
#### Status Changes
```
[2/11/2026, 4:15:00 PM] [STATUS] <@123456789>(Username-123456789) status changed: Online → Away/Idle
[2/11/2026, 4:30:22 PM] [STATUS] <@123456789>(Username-123456789) status changed: Away/Idle → Offline
```
#### Messages
```
[2/11/2026, 5:00:12 PM] [MESSAGE] <@123456789>(Username-123456789) sent in general(987654321) in ServerName(111222333): "hello world"
```
#### Typing
```
[2/11/2026, 5:05:40 PM] [TYPING] <@123456789>(Username-123456789) started typing in general(987654321) in ServerName(111222333)
```
**Note**: In DMs, the channel name is replaced with the recipient's username (e.g. `started typing in Alice(123456789) in DM`).
#### System Events
```
[2/11/2026, 2:00:00 PM] [SYSTEM] WatchCord started
```
## 🔔 Webhook Integration
### Setup
1. Create a Discord webhook in your server:
- Server Settings → Integrations → Webhooks → New Webhook
- Copy the webhook URL
2. Paste the URL in WatchCord settings → Webhook URL
3. Save settings
### Webhook Message Format
#### Voice Activity
```
`[2/11/2026, 3:45:12 PM]` 🟢 <@123456789>(Username) joined General in ServerName
`[2/11/2026, 3:47:30 PM]` 🔴 <@123456789>(Username) left General in ServerName
```
#### Status Changes
```
`[2/11/2026, 4:15:00 PM]` <@123456789>(Username) status changed: Online → Away/Idle
```
#### Messages
```
`[2/11/2026, 5:00:12 PM]` 💬 <@123456789>(Username) sent in #general in ServerName: "hello world"
[Go to message](https://discord.com/channels/111222333/987654321/555555555)
```
The channel renders as a clickable link, and `[Go to message]` jumps directly to the message in Discord.
#### Typing
```
`[2/11/2026, 5:05:40 PM]` ⌨️ <@123456789>(Username) started typing in #general in ServerName
```
The channel renders as a clickable link.
**Note**: For DMs (which have no guild), the channel link falls back to the recipient's name, and the message jump link uses `@me` as the guild segment.
**Note**: User mentions (`<@123456789>`) will be clickable in Discord if they share servers with the webhook
## 📝 Advanced Logging Features
### Channel Member Tracking
When a watched user joins a voice channel, WatchCord automatically logs:
- The user joining the channel
- All existing members already in the channel (with usernames and IDs)
- If the channel is empty, it explicitly notes "Empty channel"
**Example scenario:**
```
Alice (watched user) joins "General Voice"
Bob and Charlie are already in the channel
```
**Log output:**
```
[2/11/2026, 3:45:12 PM] [VOICE] <@111111111>(Alice-111111111) joined General(987654321) in MyServer(123456789)
└─ Existing users in channel: Bob(222222222), Charlie(333333333)
```
### Associated User Tracking
WatchCord monitors voice activity around watched users by logging when:
- Someone joins a channel where a watched user is present
- Someone leaves a channel where a watched user is present
**Example scenario:**
```
Alice (watched user) is in "General Voice"
Bob joins the same channel
```
**Log output:**
```
[2/11/2026, 3:50:00 PM] [VOICE] <@222222222>(Bob-222222222) joined <@111111111>(Alice)'s channel General(987654321) in MyServer(123456789)
```
**Benefits:**
- See who is interacting with watched users
- Track social patterns and voice channel usage
- Identify who joins/leaves when specific people are present
**Important Notes:**
- These detailed logs are **only saved to the local log file**, not sent to webhooks
- Webhooks only receive simplified notifications about the watched user's own activity
- This prevents webhook spam while maintaining detailed local records
## 🎯 Use Cases
### Parental Monitoring
- Track when children join voice channels
- Monitor their online hours and status
### Community Management
- Monitor VIP members or moderators
- Track staff availability and activity
### Personal Security
- Monitor your own account across different devices
- Get alerted to unusual activity
### Research & Analytics
- Collect data on user behavior patterns
- Analyze voice channel usage statistics
## 🔧 Technical Details
### File Structure
```
watchCord/
├── index.tsx # Main plugin logic, UI components, event handlers
├── native.ts # Node.js/Electron file operations, webhook requests
└── README.md # This file
```
### Data Storage
- **Log File Location**: `%APPDATA%/discord/watchcord-logs.txt` (Windows)
- **Full Status Changes**: `%APPDATA%/discord/watchcord-full-status-changes.json` (Windows)
- **Watch List**: Stored in Vencord settings (JSON format)
- **In-Memory Logs**: Last 500 entries for quick access
### Full Status Change Logging
For debugging and advanced analysis, WatchCord logs the **complete status change object** from Discord to a separate JSON file.
**File**: `watchcord-full-status-changes.json`
**Format**: Each entry contains:
- **timestamp**: ISO 8601 timestamp
- **data**: Complete status change object from Discord's PRESENCE_UPDATES event
**Example entry**:
```json
{
"timestamp": "2026-02-26T15:30:45.123Z",
"data": {
"user": {
"id": "123456789",
"username": "ExampleUser",
"discriminator": "0001",
"avatar": "abc123...",
"bot": false,
"system": false
},
"status": "idle",
"activities": [
{
"name": "Visual Studio Code",
"type": 0,
"created_at": 1708960245000
}
],
"client_status": {
"desktop": "idle"
},
"guildId": "987654321"
}
}
---
```
**Benefits**:
- Full Discord presence data for debugging
- See activities, client status, and all metadata
- Useful for understanding Discord's status system
- Can be parsed programmatically for analysis
**Access**: Use the "Open Full Status Changes" button in the Logs Viewer
### Event Listeners
- `VOICE_STATE_UPDATES`: Monitors voice channel activity
- `PRESENCE_UPDATES`: Tracks online status changes
- `MESSAGE_CREATE`: Logs messages sent by watched users (skips your own `optimistic` messages)
- `TYPING_START`: Logs when watched users start typing (your own typing is ignored)
### Status Labels
| Discord Status | Display Label |
| -------------- | -------------- |
| `online` | Online |
| `idle` | Away/Idle |
| `dnd` | Do Not Disturb |
| `offline` | Offline |
| `invisible` | Invisible |
## 🎨 UI Features
### Toolbar Button
- **Location**: Top toolbar (next to inbox)
- **Icon**: Eye/watch icon
- **Action**: Opens Vencord plugin settings
### Notification Sound
- **Type**: Procedurally generated beep
- **Frequency**: 800 Hz sine wave
- **Duration**: 0.5 seconds
- **Volume**: 30% (0.3 gain)
## 🐛 Troubleshooting
### Notifications Not Showing
1. Check if "Enable Notifications" is enabled in settings
2. Ensure Discord has notification permissions in your OS
3. Check browser/client notification settings
### Webhook Not Working
1. Verify webhook URL is correct and active
2. Check console for error messages (Ctrl+Shift+I)
3. Ensure webhook has permission to send messages
4. Test webhook with a curl command or webhook tester
### User Not Being Tracked
1. Verify User ID is correct
2. Check if tracking options are enabled (Voice/Status/Messages/Typing) for that entry
3. Ensure server selection matches where you want to track
4. User must be in a mutual server with you
### Messages or Typing Not Logging
1. Make sure **Messages** / **Typing** is ticked for the entry (use the inline checkboxes in the watch list)
2. Turn on **Debug Mode**, open DevTools (Ctrl+Shift+I) → Console, and filter by `WatchCord`
3. Trigger the event from the **watched** account — your own messages are skipped (`optimistic`) and your own typing never fires `TYPING_START`
4. Read the `reason` in the log: it shows whether the user isn't watched, the flag is off, or the guild doesn't match
5. For DMs, the entry must use **All Servers (*)**
### Logs Not Saving
1. Check file system permissions
2. Look for errors in DevTools console
3. Verify `watchcord-logs.txt` exists in Discord's app data folder
### Sound Not Playing
1. Check system audio settings
2. Verify "Play Sound" options are enabled for the user
3. Check browser audio permissions
4. Ensure volume is not muted
## 📝 Privacy & Ethics
**Important Considerations:**
⚠️ **User Privacy**: This plugin tracks other users' activity. Please use responsibly and ethically.
- Only track users with their knowledge and consent when possible
- Be aware of privacy laws in your jurisdiction
- Don't use this plugin to harass or stalk users
- Consider informing tracked users about monitoring
- Respect Discord's Terms of Service
**Data Security:**
- Logs are stored locally on your device
- Webhook data is transmitted over HTTPS
- No data is sent to third-party services (except configured webhooks)
## 📄 License
This plugin is part of Vencord and is licensed under GPL-3.0-or-later.
```
Vencord, a Discord client mod
Copyright (c) 2026 Vendicated and contributors
SPDX-License-Identifier: GPL-3.0-or-later
```
## 🤝 Contributing
Contributions are welcome! Please follow Vencord's contribution guidelines.
### Feature Ideas
- [ ] Export logs to CSV/JSON
- [ ] Activity graphs and statistics
- [ ] Custom notification sounds
- [ ] Regex-based filters for logs
- [ ] Schedule-based tracking (only track during certain hours)
- [ ] Multiple webhook support
## 📞 Support
For issues or questions:
1. Check the troubleshooting section above
2. Review Vencord's documentation
3. Open an issue in the Vencord repository
## 🙏 Acknowledgments
- Built for [Vencord](https://vencord.dev/)
- Thanks to the Vencord team and contributors
- Inspired by user activity monitoring needs in Discord communities
---
**Version**: 1.0.0
**Last Updated**: February 2026
**Compatibility**: Vencord (Discord Desktop/Web)
+373
View File
@@ -0,0 +1,373 @@
# WatchCord — Detailed Documentation
## Architecture Overview
WatchCord monitors Discord user activity (voice channel changes, online status changes, sent messages, and typing events) for a configurable list of users. Events are logged to a local file, shown in an in-app viewer, optionally sent to a webhook, and can trigger desktop notifications and sound alerts.
```
┌─────────────────────────────────────────────────────┐
│ WatchCord Plugin │
├─────────────────────────────────────────────────────┤
│ Settings UI │
│ ├─ WatchListManager — add/remove watched users │
│ └─ LogsViewer — view/filter/clear logs │
├─────────────────────────────────────────────────────┤
│ Toolbar Button (eye icon) → opens plugin settings │
├─────────────────────────────────────────────────────┤
│ Flux Handlers │
│ ├─ VOICE_STATE_UPDATES — voice join/leave/move │
│ ├─ PRESENCE_UPDATES — online status changes │
│ ├─ MESSAGE_CREATE — watched user sends message │
│ └─ TYPING_START — watched user starts typing │
├─────────────────────────────────────────────────────┤
│ Core Logic (renderer) │
│ ├─ addLog() — in-memory + file logging │
│ ├─ sendWebhookMessage() — optional remote logging │
│ ├─ showNotification() — native desktop notifications│
│ └─ playNotificationSound() — WebAudio beep │
├─────────────────────────────────────────────────────┤
│ Native Module (native.ts) │
│ ├─ appendLog / clearLogs / openLogFile │
│ ├─ sendWebhook │
│ └─ logFullStatusChange / openStatusChangeFile / clearStatusChanges │
└─────────────────────────────────────────────────────┘
```
## Data Types
### WatchItem (persisted)
```ts
interface WatchItem {
id: string; // unique ID (Date.now().toString())
odUserId: string; // Discord user ID
guildId: string; // Server ID or "*" for all servers
watchVoice: boolean; // track voice channel changes
watchStatus: boolean; // track online status changes
watchMessage: boolean; // track sent messages
watchTyping: boolean; // track typing events
playVoiceSound: boolean; // play sound on voice events
playStatusSound: boolean;// play sound on status events
}
```
### LogEntry (in-memory only)
```ts
interface LogEntry {
timestamp: string; // localized timestamp from getTimestamp()
type: "voice" | "status" | "message" | "typing";
message: string;
}
```
### Module-level state
| Variable | Type | Purpose |
|----------|------|---------|
| `logs` | `LogEntry[]` | In-memory cache of last 500 entries |
| `previousStatuses` | `Map<userId, status>` | Tracks last known status per user |
| `previousVoiceChannels` | `Map<userId, channelId>` | Tracks last known voice channel per user |
## Settings
| Setting | Type | Default | Description |
|---------|------|---------|-------------|
| `webhookUrl` | String | `""` | Discord webhook URL for remote logging (empty = disabled) |
| `enableNotifications` | Boolean | `true` | Show native desktop notifications |
| `debugMode` | Boolean | `false` | Log verbose debug trace to the DevTools console |
| `watchListManager` | Component | — | UI for managing watched users |
| `logsViewer` | Component | — | UI for viewing/clearing logs |
## Persistence
The watch list is stored as JSON in `Vencord.Settings.plugins.WatchCord.watchList`.
```ts
function getWatchList(): WatchItem[] {
const stored = Vencord.Settings.plugins.WatchCord?.watchList;
return stored ? JSON.parse(stored) : [];
}
function setWatchList(list: WatchItem[]) {
Vencord.Settings.plugins.WatchCord.watchList = JSON.stringify(list);
}
```
## Logging Pipeline
### addLog(type, message)
1. Creates a `LogEntry` with current timestamp
2. Prepends to in-memory `logs` array
3. Trims to the last 500 entries
4. Formats `[timestamp] [TYPE] message`
5. Writes to file via `Native.appendLog()`
```
Event detected
│
▼
addLog("voice" | "status" | "message" | "typing", message)
│
├─ logs.unshift(entry) → in-memory cache (last 500)
├─ Native.appendLog(logLine) → watchcord-logs.txt on disk
└─ (optional) sendWebhookMessage → Discord webhook
```
## Feature Workflows
### Voice Activity Tracking
`VOICE_STATE_UPDATES` fires for each changed voice state. For each state:
```
VOICE_STATE_UPDATES({ voiceStates })
│
├─ Load watchList; skip if empty
│
▼
for each state:
│
├─ Capture userId, channelId, guildId
├─ prevChannelId = previousVoiceChannels.get(userId)
├─ Update previousVoiceChannels
│
├─ Match watched user (watchVoice && guild matches)
│ └─ Skip if channelId === prevChannelId (no change)
│ └─ Log "left old channel" (if prevChannelId)
│ └─ Log "joined new channel" (if channelId)
│ └─ Log existing users in the new channel
│ └─ Play voice sound (if enabled)
│
├─ Associated-activity tracking:
│ For each watched user, detect OTHER users joining/leaving
│ the watched user's current channel
│
└─ Desktop notification (for watched user's own movement)
```
**Message examples:**
```
<@123>(User-123) joined General(987) in ServerName(111)
└─ Existing users in channel: Alice(222), Bob(333)
<@123>(User-123) left General(987) in ServerName(111)
<@444>(David-444) joined <@123>(User)'s channel General(987) in ServerName(111)
```
### Status Change Tracking
`PRESENCE_UPDATES` fires for each presence update. For each update:
```
PRESENCE_UPDATES({ updates })
│
├─ Load watchList; skip if empty
│
▼
for each update:
│
├─ Capture user.id, status, guildId
├─ prevStatus = previousStatuses.get(userId)
├─ Update previousStatuses
├─ Skip if prevStatus === status (no change)
│
├─ Match watched user (watchStatus && guild matches)
│ └─ Skip if prevStatus === undefined (first sighting)
│ └─ Log full status object to JSON file (Native.logFullStatusChange)
│ └─ addLog("status", "<@id>(name-id) status changed: A → B")
│ └─ sendWebhookMessage(...)
│ └─ showNotification("Status Change", ...)
│ └─ Play status sound (if enabled)
```
**Status label mapping:**
| Discord status | Display label |
|----------------|---------------|
| `online` | Online |
| `idle` | Away/Idle |
| `dnd` | Do Not Disturb |
| `offline` | Offline |
| `invisible` | Invisible |
### Associated-User Tracking
When a watched user is in a voice channel, WatchCord also logs when **other** users join or leave that same channel. This is tracked inside `VOICE_STATE_UPDATES`:
- `channelId === watchedUserChannelId && prevChannelId !== watchedUserChannelId` → someone joined the watched user's channel
- `prevChannelId === watchedUserChannelId && channelId !== watchedUserChannelId` → someone left the watched user's channel
These detailed logs are **only written to the local log file**, not sent to webhooks (to avoid spam).
### Message Watching
`MESSAGE_CREATE` fires whenever a message is created. WatchCord only reacts to messages **from a watched user** (matched on `odUserId`, never your own account):
```
MESSAGE_CREATE({ message, optimistic })
│
├─ Skip if optimistic (your own messages) or no author
│
▼
├─ userId = message.author.id
├─ channel = ChannelStore.getChannel(message.channel_id)
├─ guildId = message.guild_id ?? channel.guild_id
│ (undefined for DMs — use "*" to match)
│
├─ Match watched user (watchMessage && guild matches)
│ └─ addLog("message", "<@id>(name-id) sent in #channel(id) in guild: \"content\"")
│ └─ sendWebhookMessage("`[ts]` 💬 <@id>(name) sent in <#channelId> in guild: \"content\"" + "\n[Go to message](https://discord.com/channels/guild/channel/message)")
```
**Matching rules:**
- `item.odUserId === userId` — only the watched entry's user ID, never self
- `item.watchMessage` must be enabled
- `item.guildId === "*"` matches any server **and DMs**; otherwise the specific guild must match
- The `optimistic` flag (your own sent messages) is always skipped
**Content fallback:** attachment-only messages log `[N attachment(s)]`; empty content logs `[no text]`.
### Typing Watching
`TYPING_START` fires when **another user** starts typing (your own typing fires `TYPING_START_LOCAL`, which is intentionally ignored):
```
TYPING_START(event)
│
├─ userId = event.userId ?? event.user_id
├─ channelId = event.channelId ?? event.channel_id
│
├─ channel = ChannelStore.getChannel(channelId)
├─ guildId = event.guildId ?? event.guild_id ?? channel.guild_id
│
├─ Match watched user (watchTyping && guild matches)
│ └─ addLog("typing", "<@id>(name-id) started typing in #channel(id) in guild")
│ └─ sendWebhookMessage("`[ts]` ⌨️ <@id>(name) started typing in <#channelId> in guild")
```
**Note:** DM channel names are resolved from the recipient's username via `getChannelName()` (group DMs use the channel `name`), so DM typing/message logs show the other person's name instead of "Unknown".
## Lifecycle
### start()
1. Iterates the watch list and initializes `previousStatuses` from `PresenceStore.getStatus()` for users with `watchStatus` enabled
2. Writes a `[SYSTEM] WatchCord started` log line to file
3. Sends the startup message to the webhook (if configured)
4. Logs `WatchCord started` to console
### stop()
1. Clears `previousStatuses`
2. Clears `previousVoiceChannels`
3. Logs `WatchCord stopped` to console
## Debug Logging
All verbose diagnostic output is routed through a single helper:
```ts
debugLog(...args) // prefixes every line with [WatchCord]
```
It is **disabled by default** and only prints when the **Debug Mode** setting is enabled. This keeps the console clean during normal use while allowing a full trace of the message/typing pipeline when troubleshooting.
When enabled, DevTools (Ctrl+Shift+I) → Console shows:
- **On start** — the raw persisted `watchList` string and the parsed/normalized entries
- **`MESSAGE_CREATE`** — the raw event fields (`optimistic`, `authorId`, `channelId`, `guildId`, `content`), each skip decision, the current watch list, and either the matched log line or a `reason` explaining why no match occurred
- **`TYPING_START`** — the raw event, plus the same match decision / `reason` detail
`reason` is one of: `user is not in the watch list`, `watchMessage`/`watchTyping` is `OFF for this entry`, or a `guild mismatch` (with both guild IDs shown).
> Note: `TYPING_START` fires for **everyone** typing in channels you can see, so enabling Debug Mode can be noisy in busy servers. Turn it back off once you're done troubleshooting.
## Native Module (native.ts)
Runs in Electron's main process via IPC (`VencordNative.pluginHelpers.WatchCord`). All file I/O and webhook requests happen here.
| Function | Purpose |
|----------|---------|
| `appendLog(logLine)` | Append a line to `watchcord-logs.txt` |
| `clearLogs()` | Truncate `watchcord-logs.txt` |
| `openLogFile()` | Open the log file in the default editor (creates if missing) |
| `sendWebhook(url, content)` | POST a Discord webhook message |
| `logFullStatusChange(obj)` | Append a full status object to `watchcord-full-status-changes.json` |
| `openStatusChangeFile()` | Open the status-changes file |
| `clearStatusChanges()` | Truncate the status-changes file |
**File locations** (relative to Electron `app.getPath("userData")`):
| File | Path |
|------|------|
| Logs | `<userData>/watchcord-logs.txt` |
| Full status changes | `<userData>/watchcord-full-status-changes.json` |
## Settings UI
### WatchListManager
Adds/removes watched users with per-user toggles:
- **User ID** — text input
- **Server** — dropdown (All Servers or a specific server)
- **Watch Voice** — track voice activity
- **Watch Status** — track status changes
- **Watch Messages** — log when the user sends a message
- **Watch Typing** — log when the user starts typing
- **Voice Sound** — play sound on voice events
- **Status Sound** — play sound on status events
Each entry in the "Current Watch List" also shows inline checkboxes, so existing entries can have any flag toggled on/off without removing and re-adding them. Legacy entries (saved before these fields existed) load with `watchMessage`/`watchTyping` set to `false`.
Displays the current list with username/server name and a Remove button.
### LogsViewer
- Filter dropdown: All / Voice / Status / Messages / Typing
- Auto-refreshes every 1 second
- Color-coded: green (voice), yellow (status), blue (message), purple (typing)
- Buttons: Open Log File, Open Full Status Changes, Clear Logs, Clear Status Changes
## Toolbar Button
Injected next to the inbox via a patch on `toolbar:function`. The eye icon opens Vencord plugin settings (`SettingsRouter.open("VencordPlugins")`). Wrapped in `ErrorBoundary` to avoid crashes.
## Notification Sound
Procedurally generated WebAudio beep:
- **Frequency:** 800 Hz
- **Waveform:** sine
- **Duration:** 0.5 seconds
- **Volume:** 30% (0.3 gain, exponential decay to 0.01)
## Webhook Integration
- Configured via the `webhookUrl` setting
- `Native.sendWebhook()` POSTs JSON `{ content }` to the URL
- Messages use Markdown backticks around timestamps so they render in Discord
- The channel is rendered as a clickable link via a `<#channelId>` channel mention (guild channels only; DMs fall back to the recipient's name)
- Message events append a `[Go to message](...)` jump link pointing at the message in the client
- Startup message, voice events, status changes, messages, and typing events are all sent
## Edge Cases
- **First status sighting:** `prevStatus === undefined` → status is recorded but not logged (no "unknown → online" noise)
- **Own messages/typing:** `MESSAGE_CREATE` skips `optimistic: true`, and `TYPING_START_LOCAL` is not handled — the plugin never logs your own activity
- **Direct messages:** `guildId`/`guild_id` is `undefined` for DMs; a watch entry with `guildId === "*"` matches DMs. DM channel names fall back to the recipient's username
- **Log buffer:** In-memory logs capped at 500 entries; file is unbounded
- **Missing user/guild:** Fallback to `"Unknown"` for display names
- **Guild wildcard:** `guildId === "*"` matches any server (and DMs)
- **Webhook failure:** Errors are caught and logged to console, not thrown
## File Structure
```
watchCord/
├── index.tsx # Main plugin: types, flux handlers, UI components, toolbar button
├── native.ts # Electron main-process: file I/O and webhook requests
├── README.md # User-facing documentation
└── docs/
└── workflows.md # This file — detailed architecture & workflows
```
+1083
View File
File diff suppressed because it is too large. Load diff
+90
View File
@@ -0,0 +1,90 @@
/*
* Vencord, a Discord client mod
* Copyright (c) 2026 Vendicated and contributors
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { app, IpcMainInvokeEvent, shell } from "electron";
import { appendFile, writeFile } from "fs/promises";
import { join } from "path";
const LOG_FILE = "watchcord-logs.txt";
const STATUS_CHANGE_FILE = "watchcord-full-status-changes.json";
function getLogPath(): string {
return join(app.getPath("userData"), LOG_FILE);
}
function getStatusChangePath(): string {
return join(app.getPath("userData"), STATUS_CHANGE_FILE);
}
export async function appendLog(
_: IpcMainInvokeEvent,
logLine: string
): Promise<void> {
const logPath = getLogPath();
await appendFile(logPath, logLine + "\n", "utf-8");
}
export async function clearLogs(_: IpcMainInvokeEvent): Promise<void> {
const logPath = getLogPath();
await writeFile(logPath, "", "utf-8");
}
export async function openLogFile(_: IpcMainInvokeEvent): Promise<void> {
const logPath = getLogPath();
// Create file if it doesn't exist
try {
await appendFile(logPath, "", { flag: "a" });
} catch {
// ignore
}
shell.openPath(logPath);
}
export async function sendWebhook(
_: IpcMainInvokeEvent,
webhookUrl: string,
content: string
): Promise<{ ok: boolean; error?: string }> {
try {
const res = await fetch(webhookUrl, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ content }),
});
return { ok: res.ok };
} catch (e) {
return { ok: false, error: String(e) };
}
}
export async function logFullStatusChange(
_: IpcMainInvokeEvent,
statusChangeObject: any
): Promise<void> {
const statusChangePath = getStatusChangePath();
const timestamp = new Date().toISOString();
const logEntry = {
timestamp,
data: statusChangeObject
};
await appendFile(statusChangePath, JSON.stringify(logEntry, null, 2) + "\n---\n", "utf-8");
}
export async function openStatusChangeFile(_: IpcMainInvokeEvent): Promise<void> {
const statusChangePath = getStatusChangePath();
// Create file if it doesn't exist
try {
await appendFile(statusChangePath, "", { flag: "a" });
} catch {
// ignore
}
shell.openPath(statusChangePath);
}
export async function clearStatusChanges(_: IpcMainInvokeEvent): Promise<void> {
const statusChangePath = getStatusChangePath();
await writeFile(statusChangePath, "", "utf-8");
}