aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar n0Oo0Oo0b <[email protected]>2023-08-13 19:36:25 +0800
committerGravatar n0Oo0Oo0b <[email protected]>2023-08-26 23:44:16 +0800
commite82ae2885b8f493e2d233e19d994b4dcfb4b3069 (patch)
tree7408a5de48e9ac06d63344b9a86e09422a02fb03
parentCreate ModifyConfirmationView (diff)
Ask for confirmation when an admin modifies another user's reminders
-rw-r--r--bot/exts/utils/reminders.py29
1 files changed, 21 insertions, 8 deletions
diff --git a/bot/exts/utils/reminders.py b/bot/exts/utils/reminders.py
index 43d643e8e..6853fff05 100644
--- a/bot/exts/utils/reminders.py
+++ b/bot/exts/utils/reminders.py
@@ -571,17 +571,30 @@ class Reminders(Cog):
return False
raise e
- if await has_any_role_check(ctx, Roles.admins):
+ if api_response["author"] == ctx.author.id:
+ log.debug(f"{ctx.author} is the reminder author and passes the check.")
return True
- if api_response["author"] != ctx.author.id:
- log.debug(f"{ctx.author} is not the reminder author and does not pass the check.")
- if send_on_denial:
- await send_denial(ctx, "You can't modify reminders of other users!")
- return False
+ if await has_any_role_check(ctx, Roles.admins):
+ log.debug(f"{ctx.author} is an admin, asking for confirmation to modify the reminder.")
- log.debug(f"{ctx.author} is the reminder author and passes the check.")
- return True
+ confirmation_view = ModifyConfirmationView(ctx.author)
+ await ctx.send(
+ "Are you sure you want to modify someone else's reminder?",
+ view=confirmation_view,
+ )
+ await confirmation_view.wait()
+
+ if confirmation_view.result:
+ log.debug(f"{ctx.author} has confirmed reminder modification.")
+ else:
+ log.debug(f"{ctx.author} has cancelled reminder modification.")
+ return confirmation_view.result
+
+ log.debug(f"{ctx.author} is not the reminder author and does not pass the check.")
+ if send_on_denial:
+ await send_denial(ctx, "You can't modify reminders of other users!")
+ return False
async def setup(bot: Bot) -> None: