Skip to content

finxol/moodisc

Repository files navigation

Moodisc

Discord bot for moodle

Logo

Available commands

  • /help: See a help page listing all available commands. Dynamically generated.
  • /mois: See all upcoming events for the next month.
  • /semaine: See all upcoming events for the next week

example

Setup

There are 2 options for deploying moodisc:

  1. Bare Metal
  2. Docker

Bare metal

First, clone this repository, cd into it and install dependencies

git clone https://github.com.finxol/moodisc
cd moodisc
npm install

Then get your discord and moodle tokens, and add them to your environnement

export DISCORD_TOKEN=<your discord token here>
export MOODLE_TOKEN=<your moodle token here>
export MOODLE_ID=<your moodle account id here>

You may also change the url for your moodle website in getEvents.js.

After you've added your discord bot to your desired server(s), you can start the bot.

npm run dev

If you want it to run continuously in the background and have forever installed, you can directly start the forever process with

npm start

The restart and stop scripts are also available for easily managing the process.

Docker

To deploy with docker, you need to install podman (or docker but the scripts work with podman)

Create a file called .env in which you will enter your discord and moodle details. Don't include quotes

DISCORD_TOKEN=<your discord token here>
MOODLE_TOKEN=<your moodle token here>
MOODLE_ID=<your moodle account id here>

Then you can simply use the npm scripts provided to build and run with podman

npm run docker

You can also only build with npm run docker:build or only run with npm run docker:run.

Once the build and run processes have finished, check everything is running smoothly with podman ps. You should get an output like this:

CONTAINER ID  IMAGE                     COMMAND      CREATED       STATUS             PORTS       NAMES
b5d7fbde9ab2  localhost/moodisc:latest  npm run dev  1 minute ago  Up 1 minute ago                moodisc