9.7 KiB
autoMover — Detailed Documentation
Architecture Overview
The plugin operates on a list of MoveItem entries, one per (user, server) pair. Each entry carries all configuration for that target. Entries are persisted as JSON in Vencord's plugin settings.
┌─────────────────────────────────────────────────────┐
│ autoMover Plugin │
├─────────────────────────────────────────────────────┤
│ Settings UI (MoveListManager) │
│ ├─ Add / remove / toggle entries │
│ └─ Reads/writes Vencord.Settings.plugins.autoMover │
├─────────────────────────────────────────────────────┤
│ Context Menu (user-context) │
│ ├─ Auto Mover checkbox │
│ ├─ Auto Disconnect checkbox │
│ ├─ Auto Server Mute checkbox │
│ └─ Auto Server Deafen checkbox │
├─────────────────────────────────────────────────────┤
│ Flux Handler (VOICE_STATE_UPDATES) │
│ └─ Detects voice joins → calls startMoving() │
├─────────────────────────────────────────────────────┤
│ Core Logic │
│ ├─ startMoving() — action chain with delays │
│ ├─ scheduleMove() — recursive move loop │
│ ├─ tryStartIfInVoice() — starts if user already in VC│
│ └─ toggleServerAction() — mute/deafen toggle handler │
└─────────────────────────────────────────────────────┘
Data Types
MoveItem
interface MoveItem {
id: string; // unique ID (Date.now().toString())
userId: string; // Discord user ID
guildId: string; // Server ID or "*" for all
enabled: boolean; // master toggle for move/disconnect
disconnectOnJoin: boolean; // true = disconnect, false = move loop
delay: number; // ms between moves (default: 2000)
serverMute: boolean; // server-mute on join
serverDeafen: boolean; // server-deafen on join
sendDm: boolean; // send DM before actions
dmMessage: string; // DM text
}
MoveState (runtime only, not persisted)
interface MoveState {
timer: ReturnType<typeof setTimeout> | null;
guildId: string;
}
Stored in activeMoves: Map<userId, MoveState>. Tracks running move loops.
Action Chain (startMoving)
When a user joins a voice channel and a matching entry is found, startMoving() executes the following sequential chain with a 1-second delay between each step:
User joins VC
│
▼
┌──────────────────┐
│ 1. Send DM │ if sendDm === true
│ wait 1000ms │
├──────────────────┤
│ 2. Server Mute │ if serverMute === true
│ wait 1000ms │
├──────────────────┤
│ 3. Server Deafen │ if serverDeafen === true
│ wait 1000ms │
├──────────────────┤
│ 4a. Disconnect │ if disconnectOnJoin === true → one-shot, done
│ or │
│ 4b. Move Loop │ if enabled && !disconnectOnJoin → recursive
└──────────────────┘
Each step only executes if its corresponding flag is set. Steps 1–3 are independent of steps 4a/4b — you can have server mute without any move/disconnect.
Feature Workflows
Auto-Move
VOICE_STATE_UPDATES
│
├─ state.userId matches entry.userId
├─ state.channelId is set (user joined, not left)
├─ entry.guildId matches state.guildId (or "*")
├─ entry.enabled === true
└─ entry.disconnectOnJoin === false
│
▼
startMoving(entry)
│
▼
scheduleMove(entry) ← recursive loop
│
├─ Check: entry still enabled & in move mode?
├─ Check: user still in VC & matching guild?
├─ Pick random voice channel (exclude current)
├─ PATCH /guilds/{guildId}/members/{userId} { channel_id }
└─ setTimeout(scheduleMove, entry.delay)
│
└─ repeats until user disconnects or entry disabled
Stop conditions:
- User disconnects from voice
- Entry disabled or removed
- Mode switched to disconnect
- No other voice channels available in the guild
Auto-Disconnect
VOICE_STATE_UPDATES → same filter as auto-move
│
▼
startMoving(entry)
│
├─ (DM, mute, deafen with delays if configured)
└─ PATCH /guilds/{guildId}/members/{userId} { channel_id: null }
│
└─ one-shot — no loop
Auto Server Mute
VOICE_STATE_UPDATES
│
├─ state.userId matches entry.userId
├─ state.channelId is set
├─ entry.guildId matches state.guildId (or "*")
└─ entry.serverMute === true
│
▼
startMoving(entry)
│
├─ (DM with delay if configured)
└─ PATCH /guilds/{guildId}/members/{userId} { mute: true }
Works independently — can be active alongside auto-move or auto-disconnect, or on its own.
Auto Server Deafen
Same as Auto Server Mute, but sends { deaf: true }.
Mutual Exclusion Rules
| If you enable… | This happens to the other |
|---|---|
| Auto Mover | Auto Disconnect → disabled |
| Auto Disconnect | Auto Mover → disabled |
| Server Mute | No effect on others |
| Server Deafen | No effect on others |
Server mute and deafen are fully independent — they can be combined with move, disconnect, both, or neither.
Context Menu Behavior
Right-clicking a user shows four checkboxes. The guildId from the context is used to scope the entry:
| Context | guildId value |
|---|---|
| Right-click in a server | That server's ID |
| Right-click in DMs / friends | undefined → stored as "*" (all servers) |
Checkbox logic
| Checkbox | If user NOT in list | If user IS in list |
|---|---|---|
| Auto Mover | Creates entry: enabled=true, disconnectOnJoin=false |
If same mode active → toggle off. Otherwise → switch to move, disable disconnect. |
| Auto Disconnect | Creates entry: enabled=true, disconnectOnJoin=true |
If same mode active → toggle off. Otherwise → switch to disconnect, disable move. |
| Server Mute | Creates entry: enabled=false, serverMute=true |
Toggles serverMute |
| Server Deafen | Creates entry: enabled=false, serverDeafen=true |
Toggles serverDeafen |
If the user is already in a voice channel when toggled on, the action applies immediately.
Settings UI Behavior
Same mutual exclusion rules apply as context menu. Toggling the Enabled checkbox or Disconnect checkbox:
- Stops any running move loop
- Restarts with the new configuration if the user is currently in VC
Toggling Server Mute or Server Deafen:
- Applies immediately via API if user is in VC
- Does not affect move/disconnect loops
Changing the delay:
- Takes effect on the next tick of the move loop (picked up from stored settings)
API Endpoints Used
| Action | Method | URL | Body |
|---|---|---|---|
| Move user | PATCH |
/guilds/{guildId}/members/{userId} |
{ channel_id: channelId } |
| Disconnect | PATCH |
/guilds/{guildId}/members/{userId} |
{ channel_id: null } |
| Server mute | PATCH |
/guilds/{guildId}/members/{userId} |
{ mute: true } |
| Server deafen | PATCH |
/guilds/{guildId}/members/{userId} |
{ deaf: true } |
Permissions Required
| Action | Permission |
|---|---|
| Move / Disconnect | Move Members |
| Server Mute | Mute Members |
| Server Deafen | Deafen Members |
Key Constants
| Constant | Value | Description |
|---|---|---|
ACTION_DELAY_MS |
1000 |
Delay between sequential actions in startMoving() |
| Default move delay | 2000 |
Delay between moves in the auto-move loop |
Edge Cases Handled
- User in multiple guilds' VCs:
getVoiceStateForUserreturns one state. Guild check via optionalvoiceState.guildId— only blocks on explicit mismatch. - No other voice channels: Move loop stops gracefully.
- Entry removed mid-loop:
scheduleMovere-reads the stored list each tick and bails if entry is gone. - Mode switched mid-loop:
scheduleMovechecksdisconnectOnJoinand stops if mode changed. - Rapid toggle:
stopMoving()is always called before starting a new action, preventing duplicate loops. - DM channel doesn't exist: Automatically opens a private channel via
ChannelActionCreators.openPrivateChannel.
File Structure
autoMover/
├── index.tsx # Main plugin: types, logic, UI, flux handler, context menu
├── README.md # User-facing documentation
└── docs/
└── workflows.md # This file — detailed architecture & workflows