This is a simple Discord bot built with cloudflare workers that sends birthday messages to people on their birthday. This bot is NOT built for a large bot so should only be used within small servers. The bot stores its data with cloudflare's KV storage.
To run the bot locally, first clone this repository with:
git clone https://github.com/Toffee1347/bday-bot
You'll need to have wrangler installed to run on workers. Within wrangler, you need to create a worker then copy the contents from wrangler.example.toml to wrangler.toml (and add name and KV id). To have access to birthday alerts, the server members intent needs to be enabled in the Devloper Portal.
Next add the secrets needed with (only do this if planning to run the bot on workers):
wrangler secret put <NAME> <VALUE>
The two secrets needed are token and discord_public_key (these are both for the runtime and only used in production)
The next variables needed are stored in .env
Rename .env.example to .env and add the contents listed, all variables prefixed with production_ are only needed when deploying production commands to Discord
Then run the following command to install all packages needed:
npm i
The file used to register commands is deploy-commands.js To run the file, run the following command:
node src/deploy-commands.js
Add the following options to change how it runs (If not specified, the file will have the opposite effect):
--productionor-p: Register commands using the variabled prefixed withproduction_--globalor-g: Register commands globally and not just in the server underguild_id--resetor-r: When registering commands on a guild, resets global commands
Run the following command to start the bot:
npm run devstart
This will run the bot with:
- Nodemon: When any changes are made to files, restarts the bot automatically
- Miniflare: Makes a workers environment with extra features like triggering cron jobs
To trigger the birthday cron job, run the following command (assuming the bot is running):
curl "http://localhost:8787/cdn-cgi/mf/scheduled"
To deploy to production, run the following command:
npm run publish