From 162966a72459ca11b2ff3be2508eef915be24190 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 9 Jun 2024 12:49:02 +0200 Subject: [PATCH] ?alias add improvements - Fixes an issue with error message being incorrect. - Protects eval command for being added into an alias if the user does not have permissions to it as Owner level etc. as the command is quite dangerous and should not be added by normal moderators (Could be used to nuke server for example). --- cogs/utility.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cogs/utility.py b/cogs/utility.py index b892ffc01b..c9f7b62e4b 100644 --- a/cogs/utility.py +++ b/cogs/utility.py @@ -1038,7 +1038,7 @@ async def alias_raw(self, ctx, *, name: str.lower): return await ctx.send(embed=embed) - async def make_alias(self, name, value, action): + async def make_alias(self, name, value, action, ctx): values = utils.parse_alias(value) if not values: embed = discord.Embed( @@ -1083,16 +1083,23 @@ async def make_alias(self, name, value, action): if multiple_alias: embed.description = ( "The command you are attempting to point " - f"to does not exist: `{linked_command}`." + f"to on step {i} does not exist: `{linked_command}`." ) else: embed.description = ( "The command you are attempting to point " - f"to on step {i} does not exist: `{linked_command}`." + f"to does not exist: `{linked_command}`." ) return embed else: + if linked_command == "eval" and not await checks.check_permissions(ctx, "eval"): + embed = discord.Embed( + title="Error", + description="You can only add the `eval` command to an alias if you have permissions for that command.", + color=self.bot.error_color, + ) + return embed save_aliases.append(val) if multiple_alias: embed.add_field(name=f"Step {i}:", value=utils.truncate(val, 1024)) @@ -1147,7 +1154,7 @@ async def alias_add(self, ctx, name: str.lower, *, value): ) if embed is None: - embed = await self.make_alias(name, value, "Added") + embed = await self.make_alias(name, value, "Added", ctx) return await ctx.send(embed=embed) @alias.command(name="remove", aliases=["del", "delete"])