Skip to content

Commit

Permalink
Create a .env setup with .env.local support
Browse files Browse the repository at this point in the history
  • Loading branch information
byte-sized-emi committed Mar 5, 2024
1 parent 508892e commit aba870a
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
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

0 comments on commit aba870a

Please sign in to comment.