This is a Node.js application that utilizes a discord webhook to post a question of the day from a file to a Discord channel. It reads a JSON object containing an array of questions and posts one question according to your schedule.
- Include your own questions in
questions.json
. A format is included inquestions.json.format
. - Run
npm install
to install dependencies. - Copy
.env.example
to.env
and fill in the values. - Run
node index.js
.
You can also run this bot in a Docker container. To do so, use the following commands:
# Create progress.txt file
cat 0 > "$(pwd)"/progress.txt
# Make sure to also create the questions.json file in the same directory
# Run the image
docker run -d \
-e WEBHOOK_URL="enter webhook url here" \
-e CRON_SCHEDULE="enter cron schedule here" \
-e OPTIONAL_MESSAGE_CONTENT="" \
-e TZ="Europe/Berlin" \
--mount type=bind,source="$(pwd)"/questions.json,target=/app/questions.json,readonly \
--mount type=bind,source="$(pwd)"/progress.txt,target=/app/progress.txt \
--restart always \
--name qotdbot \
mrrfv/discord-webhook-qotd-bot:latest
The command above expects that the progress.txt and questions.json files already exist, and that they are in the current directory. Change the value of the TZ
environment variable for message scheduling to work properly.
BSD 3-Clause License. See LICENSE
for more information.