Abstract
A compact Discord bot that automates a voice-channel prank sequence: a slash command selects a user, the bot moves them to a designated channel, plays an FFmpeg-backed audio clip, and cleans up on a stop command. The interesting part is wiring asynchronous Discord events to a linear audio pipeline without losing state between steps.
1. What This Is
I built this as a small experiment in Discord voice-channel automation. The bot exposes two slash commands — start and stop — and orchestrates a short sequence: resolve a target member, move them into a configured voice channel, and play a pre-loaded audio clip through the bot's voice connection. Configuration (bot token, target channel ID) lives in environment variables, keeping credentials out of the command logic.
2. How It Works
The bot runs as a standard discord.py event loop. When the prank command fires, the handler resolves the mentioned member, issues a voice-channel move via the Discord API, opens an FFmpeg-backed audio stream on the bot's voice connection, and marks the sequence as active. The stop command tears down the audio stream and resets state.
| # | Stage | Input | Tool | Output |
|---|---|---|---|---|
| 01 | Command received | Slash command + member mention | discord.py | Resolved member object |
| 02 | Channel move | Member + target channel ID | Discord API | Member in designated voice channel |
| 03 | Audio playback | Pre-loaded audio file | FFmpeg | Stream through voice connection |
| 04 | Stop / cleanup | Stop command | discord.py | Audio halted, state reset |
3. Constraints
-
Permission-dependent
The move and voice-join steps require the bot to hold Move Members and Connect permissions in the target server. Without them the sequence silently fails or raises an unhandled API error.
-
Single-target, single-clip
Only one user and one audio file are handled per invocation. There is no queue, no multi-user support, and no way to swap the clip at runtime.
-
No re-entrancy guard
If the prank command fires while a sequence is already active, the second invocation can race the first. A simple active-flag check would close that gap.
-
Demo-scope security
The bot token is read from an environment variable, but there is no rate-limiting, no role-based access control on the slash commands, and no audit logging. Fine for a private server; not for public use.
4. Next
- a. Add an active-sequence flag so a second prank command is rejected or queued instead of racing the first.
- b. Support a small playlist or user-supplied audio URL so the clip is not hard-coded to one file.
- c. Add a role check on the slash commands so only server moderators can trigger the sequence.
— end of report —