(Reminders): Small UI improvements.

This commit is contained in:
2021-09-15 22:05:34 +03:00
parent 765b8a3c2b
commit 0e63c2da7a
3 changed files with 73 additions and 49 deletions

View File

@@ -34,12 +34,11 @@ async def cmd_remindme(ctx, flags):
Usage``:
{prefix}remindme in <duration> to <task>
{prefix}remindme every <duration> to <task>
{prefix}reminders
{prefix}reminders --clear
{prefix}reminders --remove <ids>
{prefix}reminders --remove
Description:
Ask LionBot to remind you about important tasks.
Ask {ctx.client.user.name} to remind you about important tasks.
Examples``:
{prefix}remindme in 2h 20m, Revise chapter 1
{prefix}remindme every hour, Drink water!
@@ -58,6 +57,7 @@ async def cmd_remindme(ctx, flags):
live = Reminder.fetch(*(row.reminderid for row in rows))
if not ctx.args:
lines = []
num_field = len(str(len(live) - 1))
for i, reminder in enumerate(live):
@@ -110,6 +110,12 @@ async def cmd_remindme(ctx, flags):
live[index].reminderid
for index in parse_ranges(message.content) if index < len(live)
]
else:
to_delete = [
live[index].reminderid
for index in parse_ranges(ctx.args) if index < len(live)
]
if not to_delete:
return await ctx.error_reply("Nothing to delete!")
@@ -247,7 +253,10 @@ async def cmd_remindme(ctx, flags):
name="{}'s reminders".format(ctx.author.display_name),
icon_url=ctx.author.avatar_url
).set_footer(
text="For examples and usage see {}help reminders".format(ctx.best_prefix)
text=(
"Click a reminder twice to jump to the context!\n"
"For more usage and examples see {}help reminders"
).format(ctx.best_prefix)
)
await ctx.reply(embed=embed)

View File

@@ -75,7 +75,19 @@ class Reminder:
trunc_content = content[:50] + '...' * (len(content) > 50)
if self.data.interval:
repeat = "(Every `{}`)".format(strfdur(self.data.interval))
interval = self.data.interval
if interval == 24 * 60 * 60:
interval_str = "day"
elif interval == 60 * 60:
interval_str = "hour"
elif interval % (24 * 60 * 60) == 0:
interval_str = "`{}` days".format(interval // (24 * 60 * 60))
elif interval % 60 * 60 == 0:
interval_str = "`{}` hours".format(interval // (60 * 60))
else:
interval_str = "`{}`".format(strfdur(interval))
repeat = "(Every {})".format(interval_str)
else:
repeat = ""

View File

@@ -253,7 +253,10 @@ def parse_ranges(ranges_str, ignore_errors=False, separator=',', **kwargs):
integers = [int(item) for item in numbers if item.isdigit()]
if not ignore_errors and len(integers) != len(numbers):
raise SafeCancellation("Couldn't parse the provided selection!")
raise SafeCancellation(
"Couldn't parse the provided selection!\n"
"Please provide comma separated numbers and ranges, e.g. `1, 5, 6-9`."
)
return integers