See CONTRIBUTING.md for general contribution guidelines.
Warbot is written in TypeScript and runs on Node.js.
-
Install Node.
If you aren't familiar with how to do this, Discord.js has a great explanation of how to do this.
Note: Discord.js, and therefore this bot, require Node v16.6.0 at minimum.
Note: This project contains an
.nvmrcfile in case you'd like to use NVM to manage your Node installation. -
Install dependencies
$ npm install > [email protected] prepare > husky install husky - Git hooks installed up to date, audited 820 packages in 1s 59 packages are looking for funding run `npm fund` for details found 0 vulnerabilities
-
Create your local environment file
$ cp .env.sample .env
Retrieve the bot token from the Discord bot settings page and replace the
DISCORD_BOT_TOKENenvironment variable's placeholder value with the real bot token. If you do not have access to that page, ask for it in#bot_devon the Warhorn Discord server.Ask @bcm for the Warhorn app token and replace the
WARHORN_APP_TOKENenvironment variable's placeholder with the real app token. -
Run the tests
$ npm test > [email protected] test > jest --detectOpenHandles --forceExit --verbose ... Test Suites: 6 passed, 6 total Tests: 17 passed, 17 total Snapshots: 0 total Time: 1.657 s, estimated 2 s Ran all test suites.
You can also run the tests in "watch" mode, which re-runs them every time a source file changes.
$ npm run test:watch ... Test Suites: 6 passed, 6 total Tests: 17 passed, 17 total Snapshots: 0 total Time: 1.628 s, estimated 2 s Ran all test suites. Watch Usage › Press f to run only failed tests. › Press o to only run tests related to changed files. › Press p to filter by a filename regex pattern. › Press t to filter by a test name regex pattern. › Press q to quit watch mode. › Press Enter to trigger a test run.
-
Start the bot
$ npm start > [email protected] start > node dist/index.js {"@timestamp":"2022-01-01T02:35:25.838Z","log.level":"info","message":"Logged into Discord as 'bcm testbot#0942'","ecs":{"version":"1.6.0"}}
This project uses Prettier to auto-format code and ESLint to detect code quality issues.
Prettier runs in a git pre-commit hook, so code formatting will happen when you stage changes. You can also set up your editor to run it as you work.
Similarly, you can set up your editor to run ESLint as you make changes.