Discord Bot Project
Overview
This is a versatile Discord bot project, built using discord.py. The bot includes:
- Admin Commands for moderating servers
- Economy System to manage virtual currency
- Fun Commands for interactive experiences
- Role Management to assign roles based on user actions or preferences
The bot is structured with scalability in mind, using cogs to separate different functionalities and utilities for common operations.
Features
- Admin Commands: Moderation tools such as banning and kicking members.
- Economy System: Tracks user balances and allows users to earn or spend virtual currency.
- Fun Commands: Simple commands that provide entertainment, such as games or random interactions.
- Role Management: Commands that automate role assignments for users.
Setup
1. Clone the Repository
Clone the repository to your local machine:
git clone https://github.com/yourusername/discord-bot.git
cd discord-bot
2. Install Requirements
Install the necessary Python packages listed in requirements.txt:
pip install -r requirements.txt
3. Set Up Environment Variables
The bot requires environment variables for configuration. Create a .env file in the root directory and add your Discord bot token:
DISCORD_TOKEN=your_token_here
4. Run the Bot
Run the bot using the command below:
python bot.py
Folder Structure
Here’s an outline of the directory and file structure for this project:
discord-bot/
│
├── bot.py # Main bot file for initializing the bot and loading cogs
├── requirements.txt # List of required Python packages
├── .env # Environment file containing sensitive data (e.g., bot token)
│
├── cogs/ # Folder containing individual cogs for separate functionalities
│ ├── admin.py # Admin commands such as ban, kick, etc.
│ ├── economy.py # Economy-related commands
│ ├── fun.py # Fun commands for user engagement
│ └── roles.py # Commands for managing server roles
│
├── utils/ # Folder containing utility files for common functionality
│ ├── bank_functions.py # Economy and balance management functions
│ └── sql_Commands.py # Database helper functions for handling SQL commands
│
├── extras/ # Experimental or additional features (optional)
│ └── example.py
│
└── docs/ # Documentation files
└── CheckList.txt # Planning and improvement list (optional)
Usage
Commands
1. Admin Commands
!ban <member> <reason>: Bans a specified member from the server with an optional reason.!kick <member> <reason>: Kicks a specified member from the server with an optional reason.
2. Economy Commands
!balance: Check your current balance.!deposit <amount>: Deposit a specified amount to your bank.!withdraw <amount>: Withdraw a specified amount from your bank.
3. Fun Commands
!roll <number>: Rolls a random number up to the specified max.!8ball <question>: Provides a magic 8-ball response to your question.
4. Role Management Commands
!assignrole <role>: Assigns a role to a user.!removerole <role>: Removes a role from a user.
Notes
- All commands can be customized by modifying their respective cog files in
cogs/. - Admin commands require appropriate permissions (e.g., ban and kick require
Ban MembersorKick Memberspermissions).
Configuration
Permissions
Make sure your bot has the appropriate permissions for each command. You can manage permissions in the Discord Developer Portal, where you created your bot. Ensure that:
- The bot has
Administratorpermissions if needed. Intentssuch asMessage Content,Guild Presences, andGuild Membersare enabled as required by the bot.
Environment Variables
Store sensitive information like your bot token in the .env file. Avoid committing this file to version control.
Database
The bot currently uses SQLite for user and balance data. You can update sql_Commands.py and bank_functions.py in the utils folder to manage other data or switch to another database if necessary.
Contributing
Contributions are welcome! Here’s how you can contribute:
- Fork the project.
- Create a feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a pull request.
Make sure to include docstrings for any new functions and comments for complex logic to maintain readability.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contact
For support, please contact yourname@example.com.
Happy Coding!