You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
436 B
17 lines
436 B
from datetime import datetime
|
|
from typing import TYPE_CHECKING
|
|
|
|
from discord.ext.commands import BadArgument, Converter
|
|
from dateutil import parser
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
DatetimeConverter = datetime
|
|
else:
|
|
class DatetimeConverter(Converter):
|
|
async def convert(self, ctx, argument) -> datetime:
|
|
dt = parser.parse(argument)
|
|
if dt is not None:
|
|
return dt
|
|
raise BadArgument()
|