A Discord Bot that allows users to set up alarms periodic or one time alarms and receive them via DM or in a certain channel.
You can check out the bot's page on top.gg to invite AlarmBot to your server!
npm i discord.jsnpm i cronnpm i mongoosenpm i file-systemnpm i timezones.jsonnpm i winstonnpm i pm2
Steps to run the bot:
- Install
Node.Json your machine (I usev14.16.0but the latest stable version should also work, previous versions can have problems). - Install all of the necessary node modules (you can install them individually or use
nodeInstall.sh). - Go to
appsettings.jsonand insert a discord bot token in thetokenfield and a url to a mongodb database inmongo_db_url. Instructions to get a token for a discord bot. Instructions to setup a mongo database. - Use the command
$pm2 start index.jsin the project's folder.
The parameters for alarm and privateAlarm work as follows:
# Use the hash sign to prefix a comment
# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (0 - 11)
# | | | | +---- day of week (0 - 6) (Sunday=0, Monday=1, ...)
# | | | | |
# * * * * * command to be executed
Some semantics:
*/x => Every number that divides by x, for example: */15 would be 15, 30 and 45 -> For now, if you want to use this I strongly advise to use in the timezone of the bot(Dublin's time), otherwise the behavior might not be the expected.
x1,...,xn => Defines a set with specific values, for example: 1,3,5 would be mean 1, 3 and 5 ONLY.
x1-xn=> Defines a set with all values within that interval, for example : 1-5 would mean every number between 1 and 5 including the extremes, i.e. - 1,2,3,4,5.
Sending hello everyday at 19:35 (GMT) => $alarm GMT 35 19 * * * Hello!
Sending hello everyday at 19:35 for GMT timezone in #general channel => $alarm GMT 35 19 * * * Hello! #general
Sending Greetings wednesday at 19:35 => $alarm GMT 35 19 * * 3 Greetings!
Sending 1234! at the 23rd of every month at 19:35 => $alarm GMT 35 19 23 * * 1234!
Sending Goodbye every Monday, Wednesday and Friday at 19:00 => $alarm GMT 00 19 * * 1,3,5 Goodbye
Send aaa hourly from 9 to 19 everyday => $alarm GMT 0 9-19 * * * aaa
Send aaa every 30 minutes from 9 to 12(excluding) everyday => $alarm GMT */30 9-12 * * * aaa
Note: These examples also work for the privateAlarm command by replacing alarm with privateAlarm.
Sending Hello today at 19:00 for GMT timezone => $oneTimeAlarm GMT 19:00 Hello
Sending Hello via DM, today at 19:00 for GMT timezone => $oneTimeAlarm -p GMT 19:00 Hello
Sending Hello world in the 25th of April of the current year at 8:00 for GMT timezone=> $oneTimeAlarm GMT 8:00 25/04 Hello World
Sending Alarm bot do something! in the 25th of April of 2024 at 8:00 for GMT timezone => $oneTimeAlarm GMT 8:00 25/04/2024 Alarm bot do something!
Note: -p flag is used to receive a DM instead of a message in the channel.
Currently the bot has the following commands:
help- Help command with all you need to know about the bot and the commands.- Usage example:
$help
- Usage example:
activateAlarm- Reactivates a silenced alarm.- Usage example:
$activateAlarm id123
- Usage example:
activateAllAlarms- Reactives all silenced alarms.- Usage example:
$activateAllAlarm -aor$activateAllAlarm -p
- Usage example:
alarm- Sets up an alarm to the channel in which you're sending the message. If you wish to send the alarm to a specific channel, the last "word" of the message should be the channel that you desire to send the message to (examples above).- Usage example:
$alarm GMT 30 12 * * * aaa
- Usage example:
alarmHelp- Some examples and help on how to setup an alarm.- Usage example:
$alarmHelp
- Usage example:
deleteAlarm- Deletes an alarm given an id.- Usage example:
$deleteAlarm id123
- Usage example:
deleteAllAlarms- Deletes all private alarms or alarms that YOU have set in a server.- Usage example:
$deleteAllAlarms -aor$deleteAllAlarms -p
- Usage example:
editAlarm- Edits the message of an alarm using-mflag. Edits the periodicity of an alarm using the-cflag. Edits the message and periodicity of the alarm using-c -mflags.- Usage examples:
$editAlarm -m id123 Brand new message/$editAlarm -c id123 GMT 36 23 * * */$editAlarm -c -m id123 GMT 28 23 * * * 🤔 Think Tank 🤔
- Usage examples:
myAlarms- Shows you a list of your public and private alarms.- Usage example:
$myAlarms
- Usage example:
oneTimeAlarm- Sets up an one time alarm, use -p for a private alarm.- Usage example:
$oneTimeAlarm GMT 19:00 Hello
- Usage example:
ping- Just to check if the bot is alive.- Usage example:
$ping
- Usage example:
premium- Get information and the link to get AlarmBot premium (75 alarms)- Usage example:
$premium
- Usage example:
privateAlarm- Sets up a private alarm via DM.- Usage example:
$privateAlarm GMT */30 9-18 * * * aaa
- Usage example:
silenceAlarm- Silences a specific alarm, if you pass a date (ex: 22/03) it will activate once that they arrives otherwise the alarm will be silent activated again withactivateAlarm.- Usage example:
$silenceAlarm id123 23/01
- Usage example:
silenceAllAlarms- Silences all alarms until they are activated again.- Usage example:
$silenceAllAlarms -aor$silenceAllAlarms -p
- Usage example:
ttsAlarm- Creates a scheduled alarm in a channel that is read out loud by discord TTS. Same usage as alarm, only changes the command.- Usage example:
$ttsAlarm GMT 30 12 * * * aaa
- Usage example:
Join our discord server for more information: https://discord.gg/zV3xnt8zkA