galnir / Master-Bot

A Discord music bot and dashboard with slash commands, playlist support, Spotify, music quiz, saved playlists, lyrics, gifs and more
MIT License
464 stars 373 forks source link

Reminders Command - TRPC 10 & Formatted #763

Closed Bacon-Fixation closed 1 year ago

Bacon-Fixation commented 1 year ago

a Repost of #762, but formatted, and without conflicts my apologise for all of the PR's, when a conflict appears on a pr, GitHub doesn't seem to let me make changes to my Fork to resolve them (it always seem to commit to here instead). I'm probably doing something wrong, but better safe than sorry :D

Function

when bot is started, the reminders Table from Postgres is cached to redis and refreshed once a day (also checks for stale reminders that may still be in the Postgres DB due to a possible missed trigger event and either remove them or set up for the next alarm) uses Redis TTL and a keyspace event listener to trigger the notifications. Uses Direct Messages to function, and was designed to be personal reminders, so most of the responses are ephemeral. You can set reminders by Text Channel or Direct Message. All reminders are Direct Messages (can't annoy other people) if it had a repeat options, then create a new db entry when message is sent (or during clean up check at start up or daily check)

Caveat

Objectives

*Monthly option can only be used if the desired Day is less than the 28th

Much Love -Bacon

galnir commented 1 year ago

I can't get this to work for some reason, I've set the current date and time, set a reminder, got a dm that its set but when invoking /reminders view - its empty

Bacon-Fixation commented 1 year ago

Roger that, I will do more testing. (it's one of those annoying bugs, where it works for me but not for others, LOL) I have some questions

Which system (mac arm)? Is Postgres a docker container? Is the Redis server a docker container? Is the bot in a docker container? Did you use the command in a guild or in a DM to the Bot?

Note: if using docker containers for the Bot, Redis and/or Postgres, then TZ=<Time-Zone> must be added to the .env

docker will set time from the host pc, but will not set the timezone unless specified, when doing the math with the Users timeOffset can lead to the value being in the "Past" being deleted or the offset being doubled (showing the wrong time)

Much Love -Bacon

galnir commented 1 year ago

Roger that, I will do more testing. (it's one of those annoying bugs, where it works for me but not for others, LOL) I have some questions

Which system (mac arm)? Is Postgres a docker container? Is the Redis server a docker container? Is the bot in a docker container? Did you use the command in a guild or in a DM to the Bot?

Note: if using docker containers for the Bot, Redis and/or Postgres, then TZ=<Time-Zone> must be added to the .env

docker will set time from the host pc, but will not set the timezone unless specified, when doing the math with the Users timeOffset can lead to the value being in the "Past" being deleted or the offset being doubled (showing the wrong time)

Much Love -Bacon

Mac ARM, everything locally hosted. I used the command on a guild chat is that the case?

Bacon-Fixation commented 1 year ago

My apologise for the delayed response, been trying to replicate this issue, but I can't seem to match the issue on the systems I have here (windows, linux, rpi, or dockerized)

the /reminder command should work in either a DM or in a Guild channel image

The Note previously posted was an issue I ran into during Dev/Testing for compatibility with docker implementations, and was unable to reliably detect this issue to inform the user, but it only showed up when using Docker containers.

I'm really not sure why it's not working on Mac Arm (looking into either emulating or possibly refurbishing a unit from work to test with)

I'm still working on it though

Much Love -Bacon

galnir commented 1 year ago

My apologise for the delayed response, been trying to replicate this issue, but I can't seem to match the issue on the systems I have here (windows, linux, rpi, or dockerized)

the /reminder command should work in either a DM or in a Guild channel image

The Note previously posted was an issue I ran into during Dev/Testing for compatibility with docker implementations, and was unable to reliably detect this issue to inform the user, but it only showed up when using Docker containers.

I'm really not sure why it's not working on Mac Arm (looking into either emulating or possibly refurbishing a unit from work to test with)

I'm still working on it though

Much Love -Bacon

I just tried creating a new reminder named 'test', and it sent me a dm "you already have an event named test". But when I'm invoking /reminder view, it says I have no reminders

galnir commented 1 year ago

Okay so now it works, idk why it didn't work before

Bacon-Fixation commented 1 year ago

Sweet! That is strange though, still gunna try and get a Mac Arm setup soon, so I can do more thorough compatibility testing, and issue replication. (Bugs me not being able to test or provide support for features or commands for Mac users)

Much Love -Bacon