feat: Add timestamp for reminder list
All checks were successful
Build Docker / Build Docker (push) Successful in 18s
All checks were successful
Build Docker / Build Docker (push) Successful in 18s
This commit is contained in:
parent
85ef94176c
commit
80460d2203
1
bot.py
1
bot.py
@ -487,6 +487,7 @@ async def reminders(ctx):
|
|||||||
message = "Reminders:\n"
|
message = "Reminders:\n"
|
||||||
for reminder in user_reminders:
|
for reminder in user_reminders:
|
||||||
time = datetime.datetime.strptime(reminder['time'], "%Y-%m-%d %H:%M:%S")
|
time = datetime.datetime.strptime(reminder['time'], "%Y-%m-%d %H:%M:%S")
|
||||||
|
time = tools.timestamp_relative(time)
|
||||||
message += f"{time}: {reminder['text']}\n"
|
message += f"{time}: {reminder['text']}\n"
|
||||||
await ctx.response.send_message(message,ephemeral=True)
|
await ctx.response.send_message(message,ephemeral=True)
|
||||||
|
|
||||||
|
17
tools.py
17
tools.py
@ -64,18 +64,11 @@ def embed(title, description):
|
|||||||
embed.set_footer(text='Powered by Nathan.Woodburn/')
|
embed.set_footer(text='Powered by Nathan.Woodburn/')
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
def timestamp_relative(date_time):
|
||||||
|
return "<t:"+str(int(date_time.timestamp()))+":R>"
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(parse_time('1d 2h 3m 4s'))
|
|
||||||
print(parse_time('1d2h3m4s'))
|
|
||||||
print(parse_time('1d 2h 3m'))
|
|
||||||
print(parse_time('1d 2h'))
|
|
||||||
print(parse_time('1d'))
|
print(parse_time('1d'))
|
||||||
print(parse_time('1h 2m 3s'))
|
print(timestamp_relative(datetime.datetime.now()+parse_time('1d')))
|
||||||
print(parse_time('1h 2m'))
|
print(parse_time('1s'))
|
||||||
print(parse_time('1h'))
|
print(timestamp_relative(datetime.datetime.now()+parse_time('1s')))
|
||||||
print(parse_time('1m 2s'))
|
|
||||||
print(parse_time('1m'))
|
|
||||||
print(read_reminders())
|
|
||||||
store_reminder(123, datetime.datetime.now(), 'test')
|
|
||||||
print(read_reminders())
|
|
Loading…
Reference in New Issue
Block a user