Allow sending the file in follow-up message in ACL upload commands (#5685)

Added follow up message when uploading acl file in permissions cog.
This commit is contained in:
Matt Chandra 2022-06-05 11:51:02 -04:00 committed by GitHub
parent 1fd9324171
commit 5522f909bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -632,11 +632,23 @@ class Permissions(commands.Cog):
) -> None: ) -> None:
"""Set rules from a YAML file and handle response to users too.""" """Set rules from a YAML file and handle response to users too."""
if not ctx.message.attachments: if not ctx.message.attachments:
await ctx.send(_("You must upload a file.")) 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 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: 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: except yaml.MarkedYAMLError as e:
await ctx.send(_("Invalid syntax: ") + str(e)) await ctx.send(_("Invalid syntax: ") + str(e))
except SchemaError as e: except SchemaError as e: