feat: Add list reminders command
All checks were successful
Build Docker / Build Docker (push) Successful in 17s
All checks were successful
Build Docker / Build Docker (push) Successful in 17s
This commit is contained in:
parent
4a7f80e64f
commit
85ef94176c
20
bot.py
20
bot.py
@ -470,6 +470,26 @@ async def remindme(ctx, when: str, reminder: str):
|
|||||||
else:
|
else:
|
||||||
await ctx.response.send_message("Invalid time format. Please use something like `1d 3h` or `4hr`.",ephemeral=True)
|
await ctx.response.send_message("Invalid time format. Please use something like `1d 3h` or `4hr`.",ephemeral=True)
|
||||||
|
|
||||||
|
@tree.command(name="reminders", description="List reminders")
|
||||||
|
async def reminders(ctx):
|
||||||
|
reminders = read_reminders()
|
||||||
|
if len(reminders) == 0:
|
||||||
|
await ctx.response.send_message("You have no reminders.",ephemeral=True)
|
||||||
|
else:
|
||||||
|
user_reminders = []
|
||||||
|
for reminder in reminders:
|
||||||
|
# Only show reminders for the user who requested them
|
||||||
|
if reminder['user_id'] == str(ctx.user.id):
|
||||||
|
user_reminders.append(reminder)
|
||||||
|
if len(user_reminders) == 0:
|
||||||
|
await ctx.response.send_message("You have no reminders.",ephemeral=True)
|
||||||
|
else:
|
||||||
|
message = "Reminders:\n"
|
||||||
|
for reminder in user_reminders:
|
||||||
|
time = datetime.datetime.strptime(reminder['time'], "%Y-%m-%d %H:%M:%S")
|
||||||
|
message += f"{time}: {reminder['text']}\n"
|
||||||
|
await ctx.response.send_message(message,ephemeral=True)
|
||||||
|
|
||||||
@tasks.loop(seconds=10)
|
@tasks.loop(seconds=10)
|
||||||
async def check_reminders():
|
async def check_reminders():
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
Loading…
Reference in New Issue
Block a user