From ebaf45e84aeea3a009a3091f0373082924337491 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 4 Feb 2021 10:52:13 +0100 Subject: [PATCH] Switch reminder to slash commands --- extensions/reminder.py | 67 +++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/extensions/reminder.py b/extensions/reminder.py index b687dd7..528f579 100644 --- a/extensions/reminder.py +++ b/extensions/reminder.py @@ -4,10 +4,12 @@ from discord.ext import commands from discord import Embed from discord.ext.commands import BadArgument from discord.ext import tasks +from discord_slash import SlashContext, cog_ext, SlashCommandOptionType +from discord_slash.utils import manage_commands from administrator.check import is_enabled from administrator.logger import logger -from administrator import db +from administrator import db, slash from administrator.utils import time_pars, seconds_to_time_string extension_name = "reminders" @@ -17,61 +19,52 @@ logger = logger.getChild(extension_name) class Reminders(commands.Cog, name="Reminder"): def __init__(self, bot: commands.Bot): self.bot = bot + slash.get_cog_commands(self) def description(self): return "Create and manage reminders" - @commands.group("reminder", pass_context=True) + @cog_ext.cog_subcommand(base="reminder", name="add", description="Add a reminder to your reminders list", options=[ + manage_commands.create_option("message", "The message", SlashCommandOptionType.STRING, True), + manage_commands.create_option("time", "When, ?D?H?M?S", SlashCommandOptionType.STRING, True) + ]) @is_enabled() - async def reminder(self, ctx: commands.Context): - if ctx.invoked_subcommand is None: - await ctx.invoke(self.reminder_help) - - @reminder.group("help", pass_context=True) - async def reminder_help(self, ctx: commands.Context): - embed = Embed(title="Reminder help") - embed.add_field(name="reminder add