A simple, reusable Discord bot template with owner/moderator permissions, help system, cog management, and slash commands.
- Permission System: Built-in bot owner and server moderator permission controls
- Help System: Automated help command generation via decorators
- Reloadable Cogs: Easy shutdown and reboot commands
- Slash Commands: Integrated slash command support
- Clean Structure: Organized file structure for easy expansion
- Install Requirements
pip install -r requirements.txt- Configure the Bot
Edit config.py with your:
- Discord bot token
- Bot owner Discord ID
- Moderator role IDs
- Command prefix
- Other settings
- Run the Bot
# Create and activate a virtual environment (optional)
python -m venv venv
venv\Scripts\activate
# Run the bot
python main.pydiscord-bot/
├── main.py # Main bot entry point
├── config.py # Bot configuration
├── utils.py # Utility functions and decorators
├── cogs/
│ ├── commands.py # Regular command cog
│ ├── slash.py # Slash command cog
│ └── ... # Add more cogs as needed
├── requirements.txt # Python package requirements
├── .gitignore # Git ignore file
└── README.md # Documentation
Add new commands to cogs/commands.py or create new cog files. Use the decorators to specify permissions:
@commands.command()
@owner_only() # For owner-only commands
@command_help("owner", "Description of command", "usage")
async def my_command(self, ctx):
await ctx.send("Command response")@commands.command()
@mod_only() # For moderator commands
@command_help("mod", "Description of command", "usage")
async def mod_command(self, ctx):
await ctx.send("Moderator command response")@commands.command()
@command_help("general", "Description of command", "usage")
async def general_command(self, ctx):
await ctx.send("General command response")Add new slash commands to cogs/slash.py:
@app_commands.command(name="command_name", description="Command description")
@is_owner() # For owner-only commands
async def slash_command(self, interaction: discord.Interaction):
await interaction.response.send_message("Command response")To add a new cog file:
- Create a new Python file in the
cogsdirectory - Define your cog class inheriting from
commands.Cog - Add the setup function at the end of the file:
async def setup(bot):
await bot.add_cog(YourCogName(bot))The bot will automatically load all cogs in the cogs directory on startup.
- Owner: Full access to all commands
- Moderators: Access to moderation commands
- Users: Access to general commands
The help system is automatically populated from command decorators, separating commands by permission level:
!help- Shows all commands available to the user!help command_name- Shows detailed help for a specific command
This template is available for free use.
This template is designed for easy extension. Add new cogs, commands, and features as needed for your specific bot use case.
Just for Fun!