@@ -1353,6 +1353,58 @@ async def alias_rename(self, ctx, name: str.lower, *, value):
13531353 )
13541354 return await ctx .send (embed = embed )
13551355
1356+ @alias .command (name = "rename" )
1357+ @checks .has_permissions (PermissionLevel .MODERATOR )
1358+ async def alias_rename (self , ctx , name : str .lower , * , value ):
1359+ """
1360+ Rename an alias.
1361+ """
1362+ if name not in self .bot .aliases :
1363+ embed = utils .create_not_found_embed (name , self .bot .aliases .keys (), "Alias" )
1364+ return await ctx .send (embed = embed )
1365+
1366+ embed = None
1367+ if self .bot .get_command (value ):
1368+ embed = discord .Embed (
1369+ title = "Error" ,
1370+ color = self .bot .error_color ,
1371+ description = f"A command with the same name already exists: `{ value } `." ,
1372+ )
1373+
1374+ elif value in self .bot .aliases :
1375+ embed = discord .Embed (
1376+ title = "Error" ,
1377+ color = self .bot .error_color ,
1378+ description = f"Another alias with the same name already exists: `{ value } `." ,
1379+ )
1380+
1381+ elif value in self .bot .snippets :
1382+ embed = discord .Embed (
1383+ title = "Error" ,
1384+ color = self .bot .error_color ,
1385+ description = f"A snippet with the same name already exists: `{ value } `." ,
1386+ )
1387+
1388+ elif len (value ) > 120 :
1389+ embed = discord .Embed (
1390+ title = "Error" ,
1391+ color = self .bot .error_color ,
1392+ description = "Alias names cannot be longer than 120 characters." ,
1393+ )
1394+
1395+ if embed is None :
1396+ old_alias_value = self .bot .aliases [name ]
1397+ self .bot .aliases .pop (name )
1398+ self .bot .aliases [value ] = old_alias_value
1399+ await self .bot .config .update ()
1400+
1401+ embed = discord .Embed (
1402+ title = "Alias renamed" ,
1403+ color = self .bot .main_color ,
1404+ description = f'`{ name } ` has been renamed to "{ value } ".' ,
1405+ )
1406+ return await ctx .send (embed = embed )
1407+
13561408 @commands .group (aliases = ["perms" ], invoke_without_command = True )
13571409 @checks .has_permissions (PermissionLevel .OWNER )
13581410 async def permissions (self , ctx ):
0 commit comments