https://github.com/natuworkguy/discord-bot
A customizable discord bot to fit your server
https://github.com/natuworkguy/discord-bot
Last synced: about 1 year ago
JSON representation
A customizable discord bot to fit your server
- Host: GitHub
- URL: https://github.com/natuworkguy/discord-bot
- Owner: Natuworkguy
- License: mit
- Created: 2025-05-17T07:31:17.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-19T22:11:47.000Z (about 1 year ago)
- Last Synced: 2025-06-03T15:08:40.649Z (about 1 year ago)
- Language: Python
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Customizable Discord Bot
[](LICENSE)
[](https://www.python.org/)
[](https://github.com/Natuworkguy)
A simple, highly customizable Discord bot designed to give developers total control over response behavior through a single file: `responses.py`.
---
## โจ Features
- ๐งฉ **Fully Customizable**: Tailor the bot's behavior by editing `responses.py`.
- โก **Fast & Lightweight**: Minimal dependencies for quick deployment.
- ๐งช **Modular Design**: Easy to extend and maintain.
- ๐ **.env Support**: Secure your token and sensitive configuration.
---
## ๐ Project Structure
```bash
dbot/
โโโ .env # Store your Discord bot token here
โโโ banner.py # Banner display on startup
โโโ main.py # Main bot logic
โโโ responses.py # Edit this file to define custom bot responses
โโโ requirements.txt # Python package dependencies
โโโ startup.sh # Shell script to launch the bot
````
---
## ๐ ๏ธ Setup Instructions
1. **Clone the repository**:
```bash
git clone https://github.com/Natuworkguy/dbot.git
cd dbot
```
2. **Create your `.env` file** (if not present):
```
DISCORD_TOKEN=your_discord_bot_token_here
```
3. **Install dependencies**:
```bash
pip install -r requirements.txt
```
4. **Customize the bot**:
Open `responses.py` and start customizing your botโs response logic.
5. **Run the bot**:
```bash
python main.py
```
Or use the provided shell script:
```bash
./startup.sh
```
---
## ๐ง How to Customize
Open `responses.py`. This is where you define how your bot responds to different messages. You can define any number of conditions and customize replies however you want.
Default logic:
```python
class Responses:
def __init__(self):
self.mute = False
self.API_KEY = os.getenv("GCLOUD_API_KEY")
if self.API_KEY == None or self.API_KEY == '':
raise BotResponseError("Google Cloud API key in .env is empty.")
self.url = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key={self.API_KEY}"
def get_response(self, user_input: str) -> str:
if user_input == "?mute" and self.mute == False:
self.mute = True
return "Ok! I will no longer respond. Unmute me with ?unmute."
if user_input == "?unmute" and self.mute == True:
self.mute = False
return "I am no longer muted. Re-mute me with ?mute"
if self.mute:
return None
payload: dict[str: list[dict[str: list[dict[str: str|int|None]]]]] = {"contents": [{"parts":[{"text": user_input}]}]}
response = requests.post(self.url, headers={"Content-Type": "application/json"}, data=json.dumps(payload))
if response.status_code == 200:
return response.json()['candidates'][0]['content']['parts'][0]['text']
else:
raise BotResponseError(f"Request failed with status code {response.status_code}: {response.text}")
```
---
## ๐ License
This project is licensed under the [MIT License](LICENSE).
---
## ๐ค Maintainer
Made with โค๏ธ by [Natuworkguy](https://github.com/Natuworkguy)