HDD:
Rynn is sleeping 💤

Pips new task

Well from the introduction post of the Ceberus Fox Discord bot Pip is for community and fun stuff. I've started to the addon for the bot because it's sometimes a bit frustrating that I forget something. It's not to replace a calander, it's for reminding and writing tiny notes in Discord itself.

Creating & adding reminders

There are certain options for creating reminders. One way is just a plain slash command like /remindme with some parameters or a modal. I tried the modal at first, having like an UI to actually create reminders feels more comfortable. So running the command /remindme opens it, but how can I do things like setting a date or remind me in 5 minutes. Handling a date is easy, because you can do:

if (!isNaN(Date.parse(input))) {
    return new Date(input).getTime();
}

Trickier is it, when you make it more dynamic and write something like in 5 min or 30 d

const regex = /^(?:in\s*)?(\d+)\s*(m|h|d|m(ins?)|h(ours?)|d(ays?)|w(eeks?))$/;
let m;
if ((m = regex.exec(input)) !== null) {
    const [_, num, unit] = m;
    switch (unit[0]) {
        case 'm': ms = parseInt(num, 10) * 60_000; break;
        case 'h': ms = parseInt(num, 10) * 3_600_000; break;
        case 'd': ms = parseInt(num, 10) * 86_400_000; break;
        case 'w': ms = parseInt(num, 10) * 604_800_000; break;
    }
}

There is also a second option to create reminders, let's say the bot and you are on a server, there is an important message and you want a reminder. You can rightclick the message and set a reminder, set the time when you want the remider and add a tiny note to it. I guess this keeps it somehow simple.

Managing reminders

List reminders

With the command /listreminders you can get all your next reminders, old reminders will be deleted after 15 minutes when the desired remind date is over. discord-remind-list.png (Screenshot of the remind list)

Delete reminders

TBD / auto delete after 15 min after the notification is sent or if the notification fails, 15 min after the date.

Database

As database I keep it simple, I used just a tiny sqlite file, but soon I realized to scale it. So I went to sequelize and changed every query and redone the db structure. Now the bot / guild settings and reminders can be stored in whatever.

Conclusion

Finally I get notifications... Maybe it helps me or others.


<- Back