Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a .env setup with .env.local support #203

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
MAIN_GUILD_ID=793280245359837214
MYSQL_DATABASE=USER_DB_NAME
MYSQL_USER=MYSQL_USER
MYSQL_PASSWORD=DATABASE_PASSWORD
MYSQL_HOST=localhost
MYSQL_PORT=3306
PUID=1000
PGID=1000
REDIS_PORT=6379
REDIS_HOST=localhost
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
.idea/
appdata/
appdata/
.env.local
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ hex = "0.4.3"
serial_test = "3.0.0"
time = "0.3.34"
once_cell = "1.19.0"
dotenvy = "0.15.7"
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

This is the code for the **Sebastian** Bot used on HM Discord Servers

# Local setup

Start a mariadb and redis instance, for example through the provided docker-compose:

```bash
docker compose up -d redis mariadb
```

Put your discord bot token in a `.env.local` at the root of the repo:

```bash
BOT_TOKEN=...
```

Start the bot:

```bash
cargo run
```

# Redesign documentation

In an effort to improve the Bot, the bot will be rewritten from ground up, switching from Python to Rust.
Expand Down
5 changes: 5 additions & 0 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ pub static BOT_TOKEN: OnceLock<String> = OnceLock::new();
pub static LOG_LEVEL: OnceLock<tracing::Level> = OnceLock::new();

pub fn init() {
dotenvy::dotenv().unwrap();

#[cfg(debug_assertions)]
let _ = dotenvy::from_filename(".env.local");

LOG_LEVEL.get_or_init(|| {
env::var("RUST_LOG")
.map(|level| {
Expand Down
Loading