diff --git a/.env b/.env new file mode 100644 index 0000000..1b0092e --- /dev/null +++ b/.env @@ -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 diff --git a/.gitignore b/.gitignore index ab1ad97..6fea9a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /target .idea/ -appdata/ \ No newline at end of file +appdata/ +.env.local diff --git a/Cargo.lock b/Cargo.lock index 59d5d3d..2d49c94 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -771,6 +771,7 @@ dependencies = [ name = "hm-discord-bot" version = "0.1.0" dependencies = [ + "dotenvy", "hex", "once_cell", "poise", diff --git a/Cargo.toml b/Cargo.toml index 02e8113..6c542da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/README.md b/README.md index 1a80d2c..b30ea93 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/env.rs b/src/env.rs index 8698d60..5bfd737 100644 --- a/src/env.rs +++ b/src/env.rs @@ -14,6 +14,11 @@ pub static BOT_TOKEN: OnceLock = OnceLock::new(); pub static LOG_LEVEL: OnceLock = 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| {