Skip to content

Commit

Permalink
adds env var handling
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislennon committed Jun 30, 2021
1 parent 1619538 commit 9ba7ff7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
AUTH_TOKEN=
LNBITS_HOST=https://lnbits.com
LNBITS_ADMIN_USER_ID=
LNBITS_ADMIN_API_KEY=
4 changes: 4 additions & 0 deletions Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const InteractionHandler = require(`./InteractionHandler`);
const MessageHandler = require(`./MessageHandler`);
const ReactionHandler = require(`./ReactionHandler`);

const dotenv = require('dotenv');
dotenv.config();

class Bot {
/**
* Initializes all modules, a Discord client, binds events.
Expand Down Expand Up @@ -94,6 +97,7 @@ class Bot {
onReady() {
this.InteractionHandler.updateCommands();
console.log(`Connected to Discord as ${this.client.user.username}#${this.client.user.discriminator} <@${this.client.user.id}>`);
console.log(`Using lnbits host: ${process.env.LNBITS_HOST}`)
}
}

Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,14 @@ In essence, allowing members of a Discord server to create wallets, deposit, tra

### Requirements
- A functional instance of [lnbits](https://github.com/lnbits/lnbits)
- You can host your own, or use lnbits.com
- You can host your own, or use [lnbits.com](https://lnbits.com)
- .env entry `LNBITS_HOST`
- You will need to have a user
- .env entry `LNBITS_ADMIN_USER_ID`
- You will need to have an API key for this user
- .env entry `LNBITS_ADMIN_API_KEY`
- You will need to have the "User Manager" extension enabled
- //TODO This will likely be replaced with a Discord extension to handle the mapping of Discord userids to lnbits users
- A Discord server that you administer or a willing admin from another server
- A Discord bot user (for more detailed steps see [here](./docs/discord_bot.md))
- _This provides AUTH_TOKEN_
Expand Down
31 changes: 17 additions & 14 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
},
"license": "GPL-2.0",
"dependencies": {
"discord.js": "^13.0.0-dev.dec191aa1e4f22690285ca06c6eee7e6086b2930"
"discord.js": "^13.0.0-dev.dec191aa1e4f22690285ca06c6eee7e6086b2930",
"dotenv": "^10.0.0",
"node-fetch": "^2.6.1"
},
"engines": {
"node": "^14.17.0"
"node": ">14.17.0"
},
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 9ba7ff7

Please sign in to comment.