This is the discord bot for c0d3, it performs discord related actions, like messaging in channels and direct messaging users for the c0d3 app.
This bot can be operated by an Api documented here.
Details about the bot's design and architecture are available in this design doc.
The production bot runs on the c0d3 CapRover server and can be communicated with the Api.
* First you need to register a discord application to get the DISCORD_TOKEN
that c0d3r will use to forward your commands to your discord server. A guide for that setup can be found on the wiki page here: Registering a Discord Bot
- Run
yarn
to install dependencies - Copy and rename
example.env
to.env
and fill the required variables. - Run
yarn start
to start the bot.
- Run
docker build -t c0d3r .
to build the image - Run
docker run --env DISCORD_TOKEN=token --env BOT_TOKEN=token c0d3r
to start a new container with the bot. The env variables are required.
Notes
- The production
DISCORD_TOKEN
available to the engineering team should not be used for local development as thec0d3
discord server will end up receiving your test messages. - For testing your
BOT_TOKEN
can be any value as long as the application sending the api commands has the sameAuthorization
header token setBearer <BOT_TOKEN>
You should be able to run this curl
command to verify your c0d3r bot is running correctly
curl --location --request POST 'http://localhost:5623/api/messages/direct/<USER_ID>' \
--header 'Authorization: Bearer <BOT_TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
"message": "Good Job! You are ready to c0d3"
}'
* replace <BOT_TOKEN>
& <USER_ID>
with their correct corresponding value.
(Enable developer mode in discord to get channelId's / userId's )