|
1 | 1 | # spades
|
2 | 2 | discord.js bot template
|
| 3 | + |
| 4 | +This is a basic discord bot template written in JS, running in Node v18+. The bot is built with minimal dependencies: |
| 5 | +- [discord.js](https://discord.js.org) library to interact with the [Discord API](https://discord.com/developers/docs/intro), |
| 6 | +- [sapphire](https://www.sapphirejs.dev), a command framework as an extension of discord.js, |
| 7 | +- [esLint](https://eslint.org), a code linter for keeping code consistent across all files, |
| 8 | +- [dotenv](https://www.dotenv.org/docs) for configuring and utilizing `.env` files, |
| 9 | +- a [mongodb](https://mongodb.github.io/node-mongodb-native/) node driver, for connecting and interaction with an instance of MongoDB Atlas, |
| 10 | +- [pino](https://getpino.io/), a lightweight logger, and |
| 11 | +- [sentry](https://sentry.io) for error tracing. |
| 12 | + |
| 13 | +the idea is to get a bot up a running with logging, error tracing, database connectivity, and a solid command structure. The utilities are barebones--build them up or swap them out at your leisure. |
| 14 | + |
| 15 | +## getting started |
| 16 | +tap the "Use this template" and create a new repository. copy the `.env.template`, rename it to `.env`, and fill out the fields with your credentials. you'll need: |
| 17 | +- a bot token, application id, and public key from Discord. you can find those in the [Discord Developer Portal](https://discord.com/developers) when you create an app, |
| 18 | +- a URI connection string from [MongoDB Atlas](https://mongodb.com), and |
| 19 | +- a client key--known as a "DSN"--from [Sentry](https://sentry.io). |
| 20 | + |
| 21 | +you may also want to install Docker and Docker Compose, if you want to run the bot in a container. |
| 22 | + |
| 23 | +once all the fields are filled out, you can: |
| 24 | +``` |
| 25 | +npm install |
| 26 | +``` |
| 27 | +then |
| 28 | +``` |
| 29 | +npm run start |
| 30 | +``` |
| 31 | +to run the bot locally through Node in your dev environment, or: |
| 32 | +``` |
| 33 | +docker compose up |
| 34 | +``` |
| 35 | +to run the bot in a Docker container. |
| 36 | + |
| 37 | +if all works well, you should see your bot active in your Discord server once you invite it. To test it, run the `/ping` command. |
| 38 | + |
| 39 | +## ongoing development |
| 40 | +active development will take place as libraries and frameworks are updated, or to improve error tracing, logging, and app monitoring. if you're interested in contributing to the source code or find a bug to report, reach out to me on [twitter](https://twitter.com/nonsensecodes); issue guides will be forthcoming. |
| 41 | + |
| 42 | +and that's it! happy building! |
0 commit comments