A powerful Discord moderation bot built with discord.py, featuring a cog-based architecture for easy maintenance and expandability.
!kick- Kick a user from the server!ban- Ban a user from the server!unban- Unban a user by their ID!mute- Mute a user (with optional duration)!unmute- Unmute a previously muted user
!purge- Delete multiple messages at once (with optional user filter)!warn- Warn a user and keep track of warnings!warnings- View a user's warning history!clearwarnings- Remove all warnings from a user!slowmode- Set slowmode delay in the current channel!lock- Lock a channel to prevent members from sending messages!unlock- Unlock a previously locked channel
!setlogchannel- Set the channel where moderation logs will be posted!setmuterole- Set the role used for muting users!createmuterole- Automatically create and set up a mute role!config- View the current bot configuration
- Clone or download this repository
- Install required dependencies:
pip install discord.py - Open
config.jsonand replace "YOUR_BOT_TOKEN_HERE" with your actual bot token - Run the bot:
python main.py
After inviting the bot to your server, follow these steps to set it up:
-
Create a mute role:
!createmuteroleThis will automatically create a "Muted" role and configure its permissions in all channels.
-
Set up a logging channel:
!setlogchannel #mod-logsReplace
#mod-logswith the channel where you want moderation actions to be logged. -
Verify your configuration:
!configThis will show your current bot settings.
When inviting the bot to your server, make sure it has the following permissions:
- Manage Roles
- Manage Channels
- Kick Members
- Ban Members
- Manage Messages
- View Audit Log
- Send Messages
- Add Reactions
- Read Message History
- View Channels
discord_moderation_bot/
├── main.py # Main bot file
├── config.json # Bot configuration
├── warnings.json # Warning storage
├── cogs/
│ ├── basic_moderation.py # Basic moderation commands
│ ├── advanced_moderation.py # Advanced moderation commands
│ ├── config.py # Configuration commands
│ └── logging.py # Event logging
To add a new cog, create a Python file in the cogs directory and use the following template:
import discord
from discord.ext import commands
class YourCogName(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command()
async def your_command(self, ctx):
"""Command description"""
# Your command code here
async def setup(bot):
await bot.add_cog(YourCogName(bot))Contributions are welcome! Feel free to submit pull requests or create issues if you find bugs or have feature suggestions.
This project is licensed under the MIT License - see the LICENSE file for details.