Discord bot for the FCSE Students Discord server, powered by discord.js 14. Requires Node.js and PostgreSQL. It is recommended to use the latest LTS versions of both.
If you would like to just run the bot:
- Download
compose.prod.yaml - Run
docker compose -f compose.prod.yaml up -d
If you wish to avoid Docker, you will have to setup your own PostgreSQL instance and set the DATABASE_URL env. variable to point to it.
This Docker image is available as ghcr.io/finki-hub/finki-discord-bot.
- Clone the repository:
git clone https://github.com/finki-hub/finki-discord-bot.git - Install dependencies (and pre-commit hooks):
npm i - Generate the database schema typings:
npm run generate - Prepare env. variables by copying
env.sampleto.env- minimum setup requiresBOT_TOKENandAPPLICATION_ID - Build the project in Docker:
docker compose build - Run it:
docker compose up -d
There is also a dev container available. To use it, just clone the repository, define the env. variables and open the container. Your development environment will be prepared automatically.
- Clone the repository:
git clone https://github.com/finki-hub/finki-discord-bot.git - Install dependencies (and pre-commit hooks):
npm i - Generate the database schema typings:
npm run generate - Make sure to have a PostgreSQL instance running
- Prepare env. variables by copying
env.sampleto.env- minimum setup requiresBOT_TOKEN,APPLICATION_IDandDATABASE_URL - Deploy latest database schema:
npm run apply - Build the project:
npm run build - Run it:
npm run start:envornpm run dev(for hot reloading)
The env. variables are stored in .env.sample. Only the BOT_TOKEN and APPLICATION_ID variables are required (for logging in to Discord) and DATABASE_URL (for the database connection).
The data for the informational commands is stored in these files. It is not required to configure them. Here is a list of all files:
classrooms.json- an array of all the classroomscourses.json- an array of the names of all coursesinformation.json- an array of all the course informationparticipants.json- an array of all courses and their number of participantsprerequisites.json- an array of course prerequisitesprofessors.json- an array of all courses and their professors and assistantsroles.json- roles for the scripts and for the embedssessions.json- an object of all exam sessionsstaff.json- an array of the staff
All the session schedule files should be placed in the sessions folder. The names of the files should match the respective names in sessions.json.
This project features integration with finki-chat-bot for enabling the FAQ and links functionality. The Discord bot fetches and mutates data from the chat bot using REST endpoints. If they are deployed in Docker, they should be on the same network to be able to communicate.
Please set the CHATBOT_URL env. variable to the URL of the chat bot.
- How to create a database migration?
- Make a change to
prisma.schemaand runnpm run migrate
- Make a change to
- How to run all database migrations?
- Run
npm run apply
- Run
- Can SQLite be used instead of PostgreSQL?
- Unfortunately, no. Prisma does not allow the database provider to be changed after creating the first migration.
- The hot reloading is too slow
- This is a Discord limitation because the bot has to relogin each time
- How do I create a Discord bot?
- "The table
public.Configdoes not exist in the current database."- You have not deployed the database migrations. Run
npm run apply
- You have not deployed the database migrations. Run
- "Error: Used disallowed intents"
- You must enable all intents in the Discord Developer Portal
- "Error [TokenInvalid]: An invalid token was provided."
- Your bot token is invalid.
This project is licensed under the terms of the MIT license.