From c36665e7550a54fa511c58cff5234bcdd4233faf Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Wed, 19 May 2021 11:39:41 +0100 Subject: [PATCH] [Modlog] Add confirmation prompt to `[p]modlogset resetcases` (#4976) * [Modlog] Confirmation for resetting modlog cases * We need to return there * Update modlog.py * style * Update redbot/cogs/modlog/modlog.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/modlog/modlog.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/modlog/modlog.py b/redbot/cogs/modlog/modlog.py index 03f677d86..f5942e8b0 100644 --- a/redbot/cogs/modlog/modlog.py +++ b/redbot/cogs/modlog/modlog.py @@ -1,3 +1,4 @@ +import asyncio from datetime import datetime, timezone from typing import Optional, Union @@ -9,6 +10,7 @@ from redbot.core.bot import Red from redbot.core.i18n import Translator, cog_i18n from redbot.core.utils.chat_formatting import box, pagify from redbot.core.utils.menus import DEFAULT_CONTROLS, menu +from redbot.core.utils.predicates import MessagePredicate _ = Translator("ModLog", __file__) @@ -101,8 +103,21 @@ class ModLog(commands.Cog): async def resetcases(self, ctx: commands.Context): """Reset all modlog cases in this server.""" guild = ctx.guild - await modlog.reset_cases(guild) - await ctx.send(_("Cases have been reset.")) + await ctx.send( + _("Are you sure you would like to reset all modlog cases in this server?") + + " (yes/no)" + ) + try: + pred = MessagePredicate.yes_or_no(ctx, user=ctx.author) + msg = await ctx.bot.wait_for("message", check=pred, timeout=30) + except asyncio.TimeoutError: + await ctx.send(_("You took too long to respond.")) + return + if pred.result: + await modlog.reset_cases(guild) + await ctx.send(_("Cases have been reset.")) + else: + await ctx.send(_("No changes have been made.")) @commands.command() @commands.guild_only()