Skip to content

Commit ab458f5

Browse files
authored
Improvements for alias creation/editing (#3422)
Improves the make_alias function.
1 parent 3c3608f commit ab458f5

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cogs/utility.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ async def alias_raw(self, ctx, *, name: str.lower):
11291129

11301130
return await ctx.send(embed=embed)
11311131

1132-
async def make_alias(self, name, value, action):
1132+
async def make_alias(self, name, value, action, ctx):
11331133
values = utils.parse_alias(value)
11341134
if not values:
11351135
embed = discord.Embed(
@@ -1176,16 +1176,23 @@ async def make_alias(self, name, value, action):
11761176
if multiple_alias:
11771177
embed.description = (
11781178
"The command you are attempting to point "
1179-
f"to does not exist: `{linked_command}`."
1179+
f"to on step {i} does not exist: `{linked_command}`."
11801180
)
11811181
else:
11821182
embed.description = (
11831183
"The command you are attempting to point "
1184-
f"to on step {i} does not exist: `{linked_command}`."
1184+
f"to does not exist: `{linked_command}`."
11851185
)
11861186

11871187
return embed
11881188
else:
1189+
if linked_command == "eval" and not await checks.check_permissions(ctx, "eval"):
1190+
embed = discord.Embed(
1191+
title="Error",
1192+
description="You can only add the `eval` command to an alias if you have permissions for that command.",
1193+
color=self.bot.error_color,
1194+
)
1195+
return embed
11891196
save_aliases.append(val)
11901197
if multiple_alias:
11911198
embed.add_field(name=f"Step {i}:", value=utils.truncate(val, 1024))
@@ -1240,7 +1247,7 @@ async def alias_add(self, ctx, name: str.lower, *, value):
12401247
)
12411248

12421249
if embed is None:
1243-
embed = await self.make_alias(name, value, "Added")
1250+
embed = await self.make_alias(name, value, "Added", ctx)
12441251
return await ctx.send(embed=embed)
12451252

12461253
@alias.command(name="remove", aliases=["del", "delete"])
@@ -1272,7 +1279,7 @@ async def alias_edit(self, ctx, name: str.lower, *, value):
12721279
embed = utils.create_not_found_embed(name, self.bot.aliases.keys(), "Alias")
12731280
return await ctx.send(embed=embed)
12741281

1275-
embed = await self.make_alias(name, value, "Edited")
1282+
embed = await self.make_alias(name, value, "Edited", ctx)
12761283
return await ctx.send(embed=embed)
12771284

12781285
@alias.command(name="rename")

0 commit comments

Comments
 (0)