Skip to content

Commit

Permalink
Rollback to support Python 3.8 and higher and modify README
Browse files Browse the repository at this point in the history
  • Loading branch information
Zalk0 committed Oct 31, 2023
1 parent 5927809 commit 14146d5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Token of the Discord bot
BOT_TOKEN=
# Log level (see logging library, defaults to INFO if not defined)
# Log level (see logging library, defaults to INFO if not defined or invalid)
LOG_LEVEL=DEBUG
# Server host and port to check if the bot is up
SERVER_HOST=localhost
Expand Down
11 changes: 7 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Ignore the dotenv
# Dotenv file
*.env

# Ignore IDE folder
# IDE folder
.idea/
.vscode/

# Ignore Python's cache
# Python's venv
venv/

# Python's cache
__pycache__/

# Ignore the logs folder
# Logs folder
logs/
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
[![Python lint](https://github.com/Zalk0/ChouetteBot-discord/actions/workflows/python-app.yml/badge.svg?branch=main)](https://github.com/Zalk0/ChouetteBot-discord/actions/workflows/python-app.yml)

Just some random project of doing a Discord bot using [discord.py](https://github.com/Rapptz/discord.py).
You need to have Python 3.11 because I use a function that was introduced in this version (in the logging library) !
You need to have Python 3.8 or higher installed (required by discord.py) !

Clone the projet and install the requirements :
Clone the projet and install the requirements (preferably in a [venv](https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments)) :

```
git clone https://github.com/Zalk0/ChouetteBot-discord.git
git clone git@github.com:Zalk0/ChouetteBot-discord.git
cd ChouetteBot-discord
pip install -r requirements.txt
```
Expand All @@ -18,7 +18,7 @@ Before launching the bot, you need to fill in a **`.env`** file (using the [temp
I provide in the repo) and put a Discord bot token inside.
To have one, go to the [Discord Developer Portal](https://discord.com/developers) and create a new application.
Go to the Bot section and click the Reset Token button, you can now claim the token.
You also have to enable all the Privileged Gateway Intents as I assume they're enabled in the code.
You also have to enable all the Privileged Gateway Intents as I assume they're enabled in the code (or change them).

---
After having done all this you can launch the bot :
Expand Down
6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def __init__(self):

# Define the bot debug log level
self.bot_logger = logging.getLogger('bot')
self.bot_logger.setLevel(logging.getLevelNamesMapping().get(self.config['LOG_LEVEL']) or logging.INFO)
log_level = logging.getLevelName(self.config['LOG_LEVEL'])
self.bot_logger.setLevel(log_level if isinstance(log_level, int) else logging.INFO)

# Set intents for the bot
intents = discord.Intents.all()
Expand Down Expand Up @@ -98,9 +99,8 @@ async def start_server(self):

# Set some basic headers for security
headers = {
"X-Frame-Options": "DENY",
"X-Content-Type-Options": "nosniff",
"Content-Security-Policy": "default-src 'self'; frame-ancestors 'none'"
"Content-Security-Policy": "default-src 'none'; frame-ancestors 'none'"
}

# Remove the Server header and apply the headers
Expand Down

0 comments on commit 14146d5

Please sign in to comment.