A Discord bot built with Python and discord.py
, designed for handling direct messages, and enabling moderators to reply to users through a dedicated channel.
- Listens for direct messages and forwards them to a moderation channel.
- Allows moderators to reply to users from a specific channel.
- Python 3.8+
discord.py
librarypython-dotenv
for environment variable managementjson
for configuration management
-
Clone the repository:
git clone https://github.com/w3nabil/discord-modmail.git cd discord-modmail
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
- Rename
.env.EXAMPLE
to.env
in the project root and add the following:BOT_TOKEN=your_discord_bot_token
- Rename
-
Configure
config.json
:- Modify the
config.json
file in the project root and structure it like this:{ "server_id": 123456789012345678, // This is your SERVER ID "mod_channel_id": 123456789012345678, // This is the channel where dms messages will be forwarded "mod_role_id": 123456789012345678 // Moderator Role, so that they can send messages }
- Modify the
-
Run the bot:
python bot.py
- Listening to DMs: Any DM sent to the bot will be forwarded to the moderation channel.
- Moderator Replies: Mods can reply using:
reply <user_id> <message>
- Bot Presence: The bot will display "Listening to People!" as its status.
- If
config.json
is missing or has incorrect values, the bot will print an error message and exit. - If the bot lacks permissions to message a user, it will notify the moderator in the channel.
- Uses lower python and discord.py version (Maybe it will be outdated soon).
- Things need to be monitored manually, for example, you need to find the text.
- Not good for servers which planning to serve 20+ users using my modmail.
- Poor Error handling, and I did not effort much for this project.
- Can not send direct images, use image cdn instead with vanity.
This project is licensed under the MIT License. See LICENSE for details.
For questions, feedback, or collaboration opportunities, feel free to reach out at [email protected].