Kardbord / Kard-bot

A Discord bot destined for greatness
GNU Affero General Public License v3.0
1 stars 0 forks source link

Custom Timezones #49

Closed Kardbord closed 2 years ago

Kardbord commented 2 years ago

This is an excellent suggestion from one of the bot's users.

Allow guild admins to create an averaged (or median?) timezone for certain members, optionally associate the TZ with a role.

To create a timezone, something like the following:

/timezone create name: FooTZ role: @foorole

To add a user to the timezone:

/timezone user-add name: FooTZ user: @someuser user-tz: UTC+2

To remove a timezone:

/timezone delete name: FooTZ

Create a message which updates itself every minute with the current time:

/timezone display name: FooTZ
Kardbord commented 2 years ago

Some "gotchas" to bear in mind:

Kardbord commented 2 years ago

See also #59?

Kardbord commented 2 years ago

This might be a good use case for Modal interactions. See #55.

Kardbord commented 2 years ago

So after doing some research, the plan for this features is going to have to change a bit.

Concerns

Rate Limiting

Making constant API requests, even at 1 minute intervals, is not going to scale well. Even if it's only for one or two messages, there's a good chance of being rate limited which will impact the UX at best and get my bot banned from the Discord API gateway at worst. Luckily DiscordGo does a good job of only sending requests at the allowed rate limit.

To mitigate the rate limiting issue, this will have to be a "server clock" feature, where only one is allowed per server. Were this a larger bot, that probably wouldn't be enough to dodge the rate limiting issue, but since the bot is not publicly hosted I think I can get away with it for now.

Privacy

The Discord API does not (and should not) provide user time zones. The server admin creating the clock will just have to provide a list of time zones they're interested in.

Moving Forward

So, the new vision I have for server clock functionality is this:

Guild admins can issue /time zone server, and provide a list of IANA time zones to average, as well as a name for the custom time zone. This will create (or replace an existing) read-only server channel. The name of the channel will be as given in the command, along with the date and time for the custom time zone. Within that channel, the bot will post a single message containing 1) The date and time of the custom time zone, and 2) the date and time of each time zone used in the calculation of the custom time zone. That message and channel name will update every one minute to reflect the current date and time. To reiterate - there may be one such channel per server.