Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds a new reminder command to the bot, allowing users to set reminders that will be sent as mentions at specified times. The reminders are stored in a database and scheduled using cron. The following changes were made:
New Command: Added a
!rem
command that takes a time (HH:MM) and a message as arguments. The command schedules a reminder at the specified time and stores the reminder in the database.Cron Job Scheduling: Implemented cron jobs to handle the scheduled reminders. When a reminder is due, the bot sends a message mentioning the user who set the reminder. The cron module is included in the "package.json".
Database Integration: Stored reminders in a database table named reminders. Each reminder includes the thread ID, user ID, reminder time, and message. If the table does not exist, it is automatically created when the bot starts.
Allowed Mentions: Ensured that user mentions in reminder messages are active by using the
allowedMentions
parameter when sending messages.Deletion Command: Added a
!delrap
command to delete a scheduled reminder by its ID. This stops the associated cron job and removes the reminder from the database.How to Use
Set a Reminder: Use the command
!rem HH:MM message
to set a reminder. The bot will confirm the scheduled time and message.Delete a Reminder: Use the command
!delrap ID
to delete a reminder by its ID.Example
!rem 14:30 Don't forget the meeting!
!delrap 1
Code Changes
The following files were modified:
docs/command.md: Added the "reminder" command to the documentation.
package.json: Added “cron” module
src/data/migrations/20171223203915_create_tables.js: Added a migration for the reminders table.
src/main.js: Added reminder module to main.js
src/modules/reminder.js: Added reminder command
Testing
Verified that reminders are stored in the database and scheduled correctly.
Ensured that reminders are sent as mentions at the correct times.
Tested the deletion of reminders and confirmed that the associated cron jobs are stopped.
Tested that reminders still work after restarting the bot
Do not hesitate to notify me of any problems.