import re from datetime import datetime, timedelta from discord.ext import commands from discord import Embed from discord.ext.commands import CommandNotFound, BadArgument, MissingRequiredArgument from discord.ext import tasks from bot_bde.logger import logger from bot_bde import db extension_name = "reminders" logger = logger.getChild(extension_name) def time_pars(s: str) -> timedelta: match = re.fullmatch(r"(?:([0-9]+)W)*(?:([0-9]+)D)*(?:([0-9]+)H)*(?:([0-9]+)M)*(?:([0-9]+)S)*", s.upper().replace(" ", "").strip()) if match: w, d, h, m, s = match.groups() if any([w, d, h, m, s]): w, d, h, m, s = [i if i else 0 for i in [w, d, h, m, s]] return timedelta(weeks=int(w), days=int(d), hours=int(h), minutes=int(m), seconds=int(s)) raise BadArgument() class Reminders(commands.Cog): def __init__(self, bot: commands.Bot): self.bot = bot @commands.group("reminder", pass_context=True) async def reminder(self, ctx: commands.Context): if ctx.invoked_subcommand is None: raise CommandNotFound() @reminder.group("help", pass_context=True) async def reminder_help(self, ctx: commands.Context): embed = Embed(title="Reminder help") embed.add_field(name="speak add