Fix reminders, use timestamps

This commit is contained in:
Zeva Rose 2022-03-23 01:25:47 -06:00
parent d3449fc5ed
commit e59e566f30

View file

@ -113,7 +113,7 @@ class RemindmeCog(Scale):
)
return
remind_at = datetime.now() + timedelta(**delta)
remind_at = datetime.utcnow() + timedelta(**delta)
r = Reminder(
user=ctx.author.id,
@ -134,7 +134,7 @@ class RemindmeCog(Scale):
EmbedField(name="Message", value=message),
EmbedField(
name="When",
value=remind_at.strftime("%Y-%m-%d %H:%M UTC"),
value=f"<t:{int(remind_at.timestamp())}:F>",
inline=False,
),
],
@ -157,7 +157,7 @@ class RemindmeCog(Scale):
if reminder.private and isinstance(ctx.channel, GuildChannel):
fields.embed(
EmbedField(
name=reminder.remind_at.strftime("%Y-%m-%d %H:%M UTC"),
name=f"<t:{int(reminder.remind_at.timestamp())}:F>",
value="Please DM me this command to view the content of this reminder",
inline=False,
)
@ -165,7 +165,7 @@ class RemindmeCog(Scale):
else:
fields.append(
EmbedField(
name=reminder.remind_at.strftime("%Y-%m-%d %H:%M UTC"),
name=f"<t:{int(reminder.remind_at.timestamp())}:F>",
value=f"{reminder.message}\n\u200b",
inline=False,
)
@ -187,15 +187,7 @@ class RemindmeCog(Scale):
@slash_command(name="reminders", sub_cmd_name="list", sub_cmd_description="List reminders")
async def _list(self, ctx: InteractionContext) -> None:
exists = self.check_cache(ctx)
if exists:
await ctx.defer(ephemeral=True)
await ctx.send(
f"Please use existing interaction: {exists['paginator']._message.jump_url}",
ephemeral=True,
)
return
reminders = await Reminder.find(q(user=ctx.author.id, active=True))
reminders = await Reminder.find(q(user=ctx.author.id, active=True)).to_list(None)
if not reminders:
await ctx.send("You have no reminders set.", ephemeral=True)
return
@ -206,7 +198,7 @@ class RemindmeCog(Scale):
@slash_command(name="reminders", sub_cmd_name="delete", sub_cmd_description="Delete a reminder")
async def _delete(self, ctx: InteractionContext) -> None:
reminders = await Reminder.find(q(user=ctx.author.id, active=True))
reminders = await Reminder.find(q(user=ctx.author.id, active=True)).to_list(None)
if not reminders:
await ctx.send("You have no reminders set", ephemeral=True)
return
@ -214,7 +206,7 @@ class RemindmeCog(Scale):
options = []
for reminder in reminders:
option = SelectOption(
label=reminder.remind_at.strftime("%Y-%m-%d %H:%M UTC"),
label=f"<t:{int(reminder.remind_at.timestamp())}:F>",
value=str(reminder.id),
emoji="",
)
@ -249,7 +241,7 @@ class RemindmeCog(Scale):
if reminder.private and isinstance(ctx.channel, GuildChannel):
fields.append(
EmbedField(
name=reminder.remind_at.strftime("%Y-%m-%d %H:%M UTC"),
name=f"<t:{int(reminder.remind_at.timestamp())}:F>",
value="Private reminder",
inline=False,
)
@ -257,7 +249,7 @@ class RemindmeCog(Scale):
else:
fields.append(
EmbedField(
name=reminder.remind_at.strftime("%Y-%m-%d %H:%M UTC"),
name=f"<t:{int(reminder.remind_at.timestamp())}:F>",
value=reminder.message,
inline=False,
)