To start up a local Guardian server, you'll first need to clone and set up dependencies:
$ git clone https://github.com/hackclub/guardian.git
$ cd guardian && yarn
You'll need access to two Airtables (one is optional): one for the Links feature, and one for the CoC Reporting table.
signing_secret="secretwooowowoowobooimaghost"
token="xoxb-numbernumbernumber"
channel="channel to post CoC reports to"
links="channel to post & receive links to shorten"
link_db_key="airtable API key for links table"
link_db="airtable db id for links"
conduct_db_key="airtable API key for the CoC reports table"
conduct_db="airtable db id for CoC reports table"
url="whatever url you're hosting Guardian on (ngrok url locally)"
There's a number of useful scripts you can use for development:
yarn lint&yarn lint:check— runs ESLint (the suffix:checkdoes not run actual formatting)yarn format&yarn format:check— runs Prettier (the suffix:checkdoes not run actual formatting)yarn check&yarn check:fix— runs both linting & formatting
Guardian is laid out using a very simple module system. All bot features are stored in src/features, and each file exports a function with type signature:
// src/features/botFeature.ts
import { App, ExpressReceiver } from 'bolt'
const botFeature: (app: App, receiver?: ExpressReceiver): void
export default botFeatureTo add a new feature, create a new file in src/features and add an export to src/features/index.ts. For the example above, you might add something like:
// src/features/index.ts
export const { default as botFeature } from './botFeature.ts`to src/features/index.ts