From f9b6f05415699bd30b4a8a3d1dbba78a44e425d5 Mon Sep 17 00:00:00 2001 From: Red-GitHubBot <88117545+Red-GitHubBot@users.noreply.github.com> Date: Sun, 5 Jun 2022 17:53:41 +0200 Subject: [PATCH] [3.4] Allow sending the file in follow-up message in ACL upload commands (#5685) (#5760) Added follow up message when uploading acl file in permissions cog. (cherry picked from commit 5522f909bd0d38ed1b80d4128b30b326af126bbf) Co-authored-by: Matt Chandra <55866950+matcha19@users.noreply.github.com> Co-authored-by: Matt Chandra <55866950+matcha19@users.noreply.github.com> --- redbot/cogs/permissions/permissions.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/redbot/cogs/permissions/permissions.py b/redbot/cogs/permissions/permissions.py index 6ec3b900e..4f0955e5c 100644 --- a/redbot/cogs/permissions/permissions.py +++ b/redbot/cogs/permissions/permissions.py @@ -634,11 +634,23 @@ class Permissions(commands.Cog): ) -> None: """Set rules from a YAML file and handle response to users too.""" if not ctx.message.attachments: - await ctx.send(_("You must upload a file.")) - return + await ctx.send(_("Supply a file with next message or type anything to cancel.")) + try: + message = await ctx.bot.wait_for( + "message", check=MessagePredicate.same_context(ctx), timeout=30 + ) + except asyncio.TimeoutError: + await ctx.send(_("You took too long to upload a file.")) + return + if not message.attachments: + await ctx.send(_("You have cancelled the upload process.")) + return + parsedfile = message.attachments[0] + else: + parsedfile = ctx.message.attachments[0] try: - await self._yaml_set_acl(ctx.message.attachments[0], guild_id=guild_id, update=update) + await self._yaml_set_acl(parsedfile, guild_id=guild_id, update=update) except yaml.MarkedYAMLError as e: await ctx.send(_("Invalid syntax: ") + str(e)) except SchemaError as e: