Skip to content

Latest commit

 

History

History
42 lines (34 loc) · 2.27 KB

README.md

File metadata and controls

42 lines (34 loc) · 2.27 KB

spades

discord.js bot template

This is a basic discord bot template written in JS, running in Node v18+. The bot is built with minimal dependencies:

  • discord.js library to interact with the Discord API,
  • sapphire, a command framework as an extension of discord.js,
  • esLint, a code linter for keeping code consistent across all files,
  • dotenv for configuring and utilizing .env files,
  • a mongodb node driver, for connecting and interaction with an instance of MongoDB Atlas,
  • pino, a lightweight logger, and
  • sentry for error tracing.

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.

getting started

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:

  • a bot token, application id, and public key from Discord. you can find those in the Discord Developer Portal when you create an app,
  • a URI connection string from MongoDB Atlas, and
  • a client key--known as a "DSN"--from Sentry.

you may also want to install Docker and Docker Compose, if you want to run the bot in a container.

once all the fields are filled out, you can:

npm install

then

npm run start

to run the bot locally through Node in your dev environment, or:

docker compose up

to run the bot in a Docker container.

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.

ongoing development

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; issue guides will be forthcoming.

and that's it! happy building!