/bot-starter

for cpsc 310 -- please ignore

Primary LanguageTypeScript

Discord ⊥ (\bot) Starter Code

All PRs merged to main go live instantly! So if you'd like a new bot feature in this discord, add it yourself 👀

Features

Commands

In all examples below, the prefix has been set to $

$help <commandName>?

Displays the list of commands. Optionally adding a command name will make the bot respond with details about the named command.

Example:

$help prefix

$prefix <newPrefix>

Updates the prefix which bot will listen to for executing commands.

This prefix should be a single, non-alphanumeric character, and it should not be one of @, /, or #.

Example:

$prefix !
!help

$recursive <boolean>

Whether the bot should be able to trigger itself.

Example:

$recursive true

$kill

What is says on the tin.

Example:

$kill

Other

  • Mention: Mentioning the bot in a message to a server channel will have it reply to you with usage instructions

Development

Contributing

To contribute just make a PR into the main branch!

  1. Click Fork button in the top right of the GitHub page
  2. Develop your feature and push to your fork
  3. Click the Pull requests tab and then the New pull request in your fork
  4. Set the base repo and branch to be this repo and main
  5. Click Create pull request

Requirements

Configuring Your Environment

  • Create a .env file and put it in the root directory of the project.
    • This file should never be committed to version control.
  • Copy .env.sample to the new .env file.
  • Modify as necessary to your environment.

Scripts

  • yarn install: Gathers all dependencies. This should be run at the start of development on a new clone in the root.
  • yarn build: Compiles the .ts files to .js files in the dist/ dir.
  • yarn lint: Lints the src/ files.
  • yarn start: Runs the bot.
  • yarn watch: Runs the bot and restarts it if any files are changed.

API

To create a Listener or Command:

  1. Create a file in either the src/listeners or src/commands directory
  2. Import the type Listener or Command from "@ubccpsc310/bot-base"
  3. Create a default export which is of type Listener or Command

Additionally, available to you is the function getDatabase() which provides an object for storing arbitrary JSON in arbitrary tables.

More information is found in the bot-base documentation.

See also