Fix some issues with remindme command

This commit is contained in:
FrozenChen
2026-06-03 20:34:25 -03:00
parent 627f89f6ea
commit c3a20b941e
3 changed files with 9 additions and 4 deletions
+6 -2
View File
@@ -498,15 +498,19 @@ class Extras(commands.GroupCog):
@commands.dynamic_cooldown(KurisuCooldown(1, 300.0), commands.BucketType.member)
@commands.hybrid_command()
async def remindme(self, ctx: KurisuContext, remind_in: int = commands.parameter(converter=DateOrTimeToSecondsConverter), *, reminder: str):
"""Sends a reminder after a set time, just for you. Max reminder size is 800 characters.
"""Sends a reminder after a set time, just for you.
Date format is only supported for slash command and date is treated as UTC.
Max reminder size is 800 characters.
Args:
remind_in: Time to remind you in can be in a #d#h#m#s format or a YYYY-MM-DD HH:MM:SS format.
remind_in: Time to remind you in, can be in a #d#h#m#s format or a YYYY-MM-DD HH:MM format.
reminder: Contents of the reminders. Max 800 characters.
"""
if remind_in < 30 or remind_in > 3.154e+7:
ctx.command.reset_cooldown(ctx)
return await ctx.send("You can't set a reminder for less than 30 seconds or for more than a year.")
if len(reminder) > 800:
ctx.command.reset_cooldown(ctx)
return await ctx.send("The reminder is too big! (Longer than 800 characters)")
timestamp = datetime.now(self.bot.tz)
delta = timedelta(seconds=remind_in)
+2 -2
View File
@@ -1,6 +1,6 @@
import discord
from datetime import datetime
from datetime import datetime, timezone
from discord import app_commands, Member
from discord.ext.commands import BadArgument, MemberConverter, ObjectConverter, MessageConverter, Context, Converter, ObjectNotFound, ChannelNotFound
from utils.utils import parse_date, parse_time
@@ -43,7 +43,7 @@ class MemberOrID(Converter):
class DateOrTimeToSecondsConverter(Converter):
async def convert(self, ctx: Context, arg: str):
if (datetime_obj := parse_date(arg)) is not None:
return int((datetime_obj - datetime.utcnow()).total_seconds())
return int((datetime_obj - datetime.now(timezone.utc)).total_seconds())
elif (seconds := parse_time(arg)) != -1:
return seconds
raise BadArgument("Invalid date/time format")
+1
View File
@@ -126,6 +126,7 @@ def parse_date(date_string: str) -> Optional[datetime.datetime]:
return None
try:
datetime_obj = datetime.datetime.strptime(' '.join(date_lst), "%Y-%m-%d %H:%M")
datetime_obj = datetime_obj.replace(tzinfo=datetime.timezone.utc)
except ValueError:
return None
return datetime_obj