added .env file

This commit is contained in:
Michael Matthews 2021-07-13 03:08:41 -04:00
parent 640e0e475c
commit 5c315db8c6
4 changed files with 11 additions and 1 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
.env
# Added by cargo
/target

7
Cargo.lock generated
View File

@ -4,6 +4,7 @@
name = "Osselbot"
version = "0.1.0"
dependencies = [
"dotenv",
"serenity",
"tokio",
]
@ -151,6 +152,12 @@ dependencies = [
"generic-array",
]
[[package]]
name = "dotenv"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "encoding_rs"
version = "0.8.28"

View File

@ -9,4 +9,5 @@ edition = "2018"
[dependencies]
serenity = { version = "0.10.8", default-features = false, features = ["client", "gateway", "rustls_backend", "model"] }
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] }
dotenv = "0.15.0"

View File

@ -1,5 +1,6 @@
#![allow(non_snake_case)] //Osselbot doesn't follow snake case so we need this
use dotenv::dotenv;
use std::env;
use serenity::{
@ -42,6 +43,7 @@ impl EventHandler for Handler {
#[tokio::main]
async fn main() {
dotenv().ok();
// Configure the client with your Discord bot token in the environment.
let token = env::var("DISCORD_TOKEN").expect("Expected a token in the environment");