A Discord bot that sends messages on a schedule using cron expressions.
-
Follow the instructions in create-discord-bot.
Don't forget to give your bot the
Manage Webhooks
permission! -
Download this bot and move the
src-discord-cron-bot
folder into the /src/bots folder from step 1.Run
npm i cron@^1.8.2
andnpm i -D @types/cron@^1.7.3
to install this bot's dependencies. -
Open config.json to configure your own settings:
{ "timezone": "America/Los_Angeles", "rules": [ { "cronExpression": "39 39 * * * *", "channelPolicy": "single", "messagePolicy": "single", "reactionPolicy": "single", "channelIds": ["747319121582096434"], "messages": [ { "content": "<@&785794153089990688>, hourly reminder to hydrate!" } ], "reactions": ["🥤"] } ] }
Add as many rules as you want to configure for other servers.
-
timezone
is the timezone you wish to localize yourcronExpression
to. -
cronExpression
is the interval at which messages are sent. -
channelPolicy
must be one of the following strings:all
: Sends to every channel inchannelIds
.random
: Sends to a single random channel inchannelIds
.single
: Sends to the first channel inchannelIds
.
-
messagePolicy
must be one of the following strings:all
: Sends all messages inmessages
.random
: Sends a single random message inmessages
.single
: Sends the first message inmessages
.
-
reactionPolicy
must be one of the following strings:all
: Reacts with all emojis inreactions
on the sent message(s).random
: Reacts with a single random emoji inreactions
on the sent message(s).single
: Reacts with the first emoji inreactions
on the sent message(s).
-
channelIds
are the text channel(s) you want your message(s) to be forwarded to. -
messages
is a list of WebhookMessageOptions. -
reactions
is a list of emojis. An emoji can be:-
A unicode emoji. https://emojipedia.org is a good reference to copy and paste from.
"😳", "🥺", // etc
-
An emoji ID for custom emojis. You can get a custom emoji's ID by sending
\:YourCustomEmoji:
in chat (prefix a backslash\
character in front of your desired emoji)."716344914706694165", "622635442013208589", // etc
-
Some useful resources:
- Moment Timezone: find your
timezone
string. - crontab guru: build your
cronExpression
. Note that the tool does not support seconds but this bot configuration does. - Embed Visualizer: visualize your message content and embeds. Switch to
webhook
mode first.
-
-
npm start
to run the bot.
Visit for more help or information!