Skip to content

Phoenix2k/discbot

Repository files navigation

# Discbot

Discord bot based on Discord.js and TypeScript.

Workflow status Current version

Requirements

Optional

Discord application

Start by creating a new Discord application:

  1. Sign-in to Discord
  2. Create an application
  3. Build a bot by going to Bot > Add Bot
  4. Once the bot is built, click the Copy button to store the token in your clipboard
  5. Start the installation process and paste the token in your terminal when asked

Installation

Clone the repository and install dependencies:

$ git clone https://github.com/Phoenix2k/discbot.git
$ cd discbot
$ nvm use
$ npm install

This will ask you to give your bot a name of your choosing and to enter the token from your Discord app.

If you need to replace these later, you can run npm run generate:env to regenerate the .env file.

Development

Source files are located in the src folder.

Start a local development instance:

$ npm run dev

This will start a local instance at http://localhost:3000. The server will restart automatically when you make changes to the source files and let you know of any errors while you develop.

Debugging mode:

$ npm run dev:debug

This is similar to dev, but will emit more log messages to give you a better understanding of what's going on behind the scenes.

Testing

Lint files

Check for coding and styling errors:

$ npm run lint

Unit tests

Tests are found in the src folder. Look for files ending with .spec.ts.

Run tests:

$ npm test

Should your tests fail, you can try clearing the cache with npm run test:clear-cache and running the tests again.

This will also generate a coverage report, which you can browse by opening coverage/lcov-report/index.html in your browser once it has been created.

Production

Build for production:

$ npm run build

Start an instance:

$ npm start

Release

Create a new release:

$ npm run release

You will need a personal access token from GitHub in order for the the script to be able to create a release on your behalf.

Follow the instructions and use common sense when choosing the version number.

Links

License

MIT