A simple and lightweight Discord bot to verify new server members using randomly generated codes.
Built using discord.py.
- Sends a welcome message when a new member joins.
- Guides users to verify themselves via Direct Message (DM).
- Generates a random 6-character code for verification.
- Times out verification codes after 5 minutes.
- Grants a "Verified" role upon successful verification.
- Deletes public verification attempts for user privacy.
git clone https://github.com/yourusername/discord-verification-bot.git
cd discord-verification-botMake sure you have Python 3.8+ installed.
pip install -r requirements.txtRequired libraries:
discord.pypython-dotenv
Or manually:
pip install discord.py python-dotenvCreate a .env file in the project root directory and add:
TOKEN=your-bot-token
GUILD_ID=your-server-id
WELCOME_CHANNEL_ID=welcome-channel-id
VERIFIED_ROLE_ID=verified-role-id- TOKEN: Your bot's token.
- GUILD_ID: Your server's ID.
- WELCOME_CHANNEL_ID: Channel ID for welcome and verification messages.
- VERIFIED_ROLE_ID: Role ID to assign after successful verification.
(Enable Developer Mode in Discord to copy IDs: Settings → Advanced → Developer Mode.)
python bot.py| Command | Description |
|---|---|
$hello |
Bot replies with "Hello!" (test command). |
$verify |
Initiates the verification process. |
$code <code> |
Submit the received code via DM to verify. |
- DMs must be enabled for the bot to contact users.
- Verification codes expire after 5 minutes.
- The bot deletes public
$codeattempts to protect user privacy. - You might want to deploy the script in an always running cloud platform.
- A new member joins the server.
- Bot sends a welcome message and asks them to type
$verify. - Member types
$verifyin the welcome channel. - Bot sends a DM with a unique code.
- Member replies with
$code XXXXXin DM. - If correct, the member gets the Verified role.
This project is open-source under the MIT License.