Skip to content

Commit e87ca0e

Browse files
committed
Keep arugments for linked alias
1 parent 5ed556d commit e87ca0e

File tree

1 file changed

+45
-24
lines changed

1 file changed

+45
-24
lines changed

cogs/utility.py

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,10 +1055,14 @@ async def alias_add(self, ctx, name: str.lower, *, value):
10551055
return await ctx.send(embed=embed)
10561056

10571057
if len(values) == 1:
1058-
linked_command = values[0].split()[0].lower()
1058+
linked_command, *messages = values[0].split(maxsplit=1)
10591059
if not self.bot.get_command(linked_command):
1060-
if linked_command in self.bot.aliases:
1061-
values = [self.bot.aliases.get(linked_command)]
1060+
alias_command = self.bot.aliases.get(linked_command)
1061+
if alias_command is not None:
1062+
if messages:
1063+
values = [f"{alias_command} {messages[0]}"]
1064+
else:
1065+
values = [alias_command]
10621066
else:
10631067
embed = discord.Embed(
10641068
title="Error",
@@ -1082,17 +1086,20 @@ async def alias_add(self, ctx, name: str.lower, *, value):
10821086
)
10831087

10841088
for i, val in enumerate(values, start=1):
1085-
linked_command = val.split()[0]
1089+
linked_command, *messages = val.split(maxsplit=1)
10861090
if not self.bot.get_command(linked_command):
1087-
if linked_command in self.bot.aliases:
1088-
index = values.index(linked_command)
1089-
values[index] = self.bot.aliases.get(linked_command)
1091+
alias_command = self.bot.aliases.get(linked_command)
1092+
if alias_command is not None:
1093+
if messages:
1094+
values = [f"{alias_command} {messages[0]}"]
1095+
else:
1096+
values = [alias_command]
10901097
else:
10911098
embed = discord.Embed(
10921099
title="Error",
10931100
color=self.bot.error_color,
10941101
description="The command you are attempting to point "
1095-
f"to on step {i} does not exist: `{linked_command}`.",
1102+
f"to n step {i} does not exist: `{linked_command}`.",
10961103
)
10971104
return await ctx.send(embed=embed)
10981105
embed.description += f"\n{i}: {val}"
@@ -1143,15 +1150,22 @@ async def alias_edit(self, ctx, name: str.lower, *, value):
11431150
return await ctx.send(embed=embed)
11441151

11451152
if len(values) == 1:
1146-
linked_command = values[0].split()[0].lower()
1153+
linked_command, *messages = values[0].split(maxsplit=1)
11471154
if not self.bot.get_command(linked_command):
1148-
embed = discord.Embed(
1149-
title="Error",
1150-
color=self.bot.error_color,
1151-
description="The command you are attempting to point "
1152-
f"to does not exist: `{linked_command}`.",
1153-
)
1154-
return await ctx.send(embed=embed)
1155+
alias_command = self.bot.aliases.get(linked_command)
1156+
if alias_command is not None:
1157+
if messages:
1158+
values = [f"{alias_command} {messages[0]}"]
1159+
else:
1160+
values = [alias_command]
1161+
else:
1162+
embed = discord.Embed(
1163+
title="Error",
1164+
color=self.bot.error_color,
1165+
description="The command you are attempting to point "
1166+
f"to does not exist: `{linked_command}`.",
1167+
)
1168+
return await ctx.send(embed=embed)
11551169
embed = discord.Embed(
11561170
title="Edited alias",
11571171
color=self.bot.main_color,
@@ -1166,15 +1180,22 @@ async def alias_edit(self, ctx, name: str.lower, *, value):
11661180
)
11671181

11681182
for i, val in enumerate(values, start=1):
1169-
linked_command = val.split()[0]
1183+
linked_command, *messages = val.split(maxsplit=1)
11701184
if not self.bot.get_command(linked_command):
1171-
embed = discord.Embed(
1172-
title="Error",
1173-
color=self.bot.error_color,
1174-
description="The command you are attempting to point "
1175-
f"to on step {i} does not exist: `{linked_command}`.",
1176-
)
1177-
return await ctx.send(embed=embed)
1185+
alias_command = self.bot.aliases.get(linked_command)
1186+
if alias_command is not None:
1187+
if messages:
1188+
values = [f"{alias_command} {messages[0]}"]
1189+
else:
1190+
values = [alias_command]
1191+
else:
1192+
embed = discord.Embed(
1193+
title="Error",
1194+
color=self.bot.error_color,
1195+
description="The command you are attempting to point "
1196+
f"to on step {i} does not exist: `{linked_command}`.",
1197+
)
1198+
return await ctx.send(embed=embed)
11781199
embed.description += f"\n{i}: {val}"
11791200

11801201
self.bot.aliases[name] = "&&".join(values)

0 commit comments

Comments
 (0)