From fa032987fe7268ea3f6a58dd14609e4925484be2 Mon Sep 17 00:00:00 2001 From: Mole1424 Date: Sat, 22 Jun 2024 18:59:34 +0000 Subject: [PATCH] added reminder clear --- cogs/commands/reminders.py | 14 ++++++++++++++ docs.md | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cogs/commands/reminders.py b/cogs/commands/reminders.py index 00480de..e6a0b99 100644 --- a/cogs/commands/reminders.py +++ b/cogs/commands/reminders.py @@ -159,6 +159,20 @@ async def remove(self, ctx: Context, reminder_id: int): else: await ctx.send("I couldn't delete the reminder you asked for") + @reminder.command() + async def clear(self, ctx: Context): + """ + Removes all your reminders. + """ + author = utils.get_database_user(ctx.author) + reminders = ( + db_session.query(Reminder) + .filter(Reminder.user_id == author.id) + .delete(synchronize_session=False) + ) + db_session.commit() + await ctx.send(f"Deleted {reminders} reminders.") + async def setup(bot: Bot): await bot.add_cog(Reminders(bot)) diff --git a/docs.md b/docs.md index fe740a0..aaa5b17 100644 --- a/docs.md +++ b/docs.md @@ -72,7 +72,7 @@ Cogs are how Discord.py organizes commands, each file is a separate cog with sep 4. Check the newly created upgrade and downgrade is correct 5. Upgrade your database with `alembic upgrade head` - If running in docker, the above is slightly different: - 1. Run `docker compose up --build d` to start apollo and postgres in the background in a docker container + 1. Run `docker compose up --build -d` to start apollo and postgres in the background in a docker container 2. Run `docker compose exec apollo alembic upgrade head` to bring the database up to date 3. Run `docker compose exec apollo alembic revision --autogenerate -m ""` to generate the migration within the container 4. Run `docker compose cp apollo:/app/migrations/versions/ ./migrations/versions` this will copy the migration out of the container and into your local directory