Skip to content

Commit

Permalink
fix: better env loading error message (#132)
Browse files Browse the repository at this point in the history
* fix: better env load error message

* docs: updated deployment instructions
  • Loading branch information
afonsojramos authored Feb 4, 2022
1 parent 6d35a93 commit f679a97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
## Deployment

### Usage
Just [create a bot account](https://github.com/aquelemiguel/parrot/wiki/Create-Your-Discord-Bot), copy its token into the `DISCORD_TOKEN` environment variable within `.env`.
Just [create a bot account](https://github.com/aquelemiguel/parrot/wiki/Create-Your-Discord-Bot), and copy its **token** and **application id** to a `.env` with the `DISCORD_TOKEN` and `DISCORD_APPID` environment variables respectively.

### Docker

Expand Down
6 changes: 4 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ pub struct Client {

impl Client {
pub async fn default() -> Result<Client, Box<dyn Error>> {
let token = env::var("DISCORD_TOKEN")?;
let token = env::var("DISCORD_TOKEN").expect("Fatality! DISCORD_TOKEN not set!");
Client::new(token).await
}

pub async fn new(token: String) -> Result<Client, Box<dyn Error>> {
let application_id = env::var("DISCORD_APPID")?.parse()?;
let application_id = env::var("DISCORD_APPID")
.expect("Fatality! DISCORD_APPID not set!")
.parse()?;

let client = serenity::Client::builder(token)
.event_handler(SerenityHandler)
Expand Down

0 comments on commit f679a97

Please sign in to comment.