3333 get_perm_level ,
3434 create_not_found_embed ,
3535 parse_alias ,
36+ format_description ,
3637)
3738
3839logger = logging .getLogger ("Modmail" )
@@ -248,11 +249,10 @@ def __init__(self, bot):
248249 verify_checks = False , command_attrs = {"help" : "Shows this help message." }
249250 )
250251 # Looks a bit ugly
251- # noinspection PyProtectedMember
252- self .bot .help_command ._command_impl = checks .has_permissions ( # pylint: disable=W0212
252+ self .bot .help_command ._command_impl = checks .has_permissions ( # pylint: disable=protected-access
253253 PermissionLevel .REGULAR
254254 )(
255- self .bot .help_command ._command_impl # pylint: disable=W0212
255+ self .bot .help_command ._command_impl # pylint: disable=protected-access
256256 )
257257
258258 self .bot .help_command .cog = self
@@ -998,19 +998,26 @@ async def alias(self, ctx, *, name: str.lower = None):
998998 embeds = []
999999
10001000 for i , names in enumerate (zip_longest (* (iter (sorted (self .bot .aliases )),) * 15 )):
1001- description = "\n " .join (
1002- ": " .join ((str (a + i * 15 ), b ))
1003- for a , b in enumerate (
1004- takewhile (lambda x : x is not None , names ), start = 1
1005- )
1006- )
1001+ description = format_description (i , names )
10071002 embed = Embed (color = self .bot .main_color , description = description )
10081003 embed .set_author (name = "Command Aliases" , icon_url = ctx .guild .icon_url )
10091004 embeds .append (embed )
10101005
10111006 session = PaginatorSession (ctx , * embeds )
10121007 await session .run ()
10131008
1009+ @alias .command (name = "raw" )
1010+ @checks .has_permissions (PermissionLevel .MODERATOR )
1011+ async def alias_raw (self , ctx , * , name : str .lower ):
1012+ """
1013+ View the raw content of an alias.
1014+ """
1015+ val = self .bot .aliases .get (name )
1016+ if val is None :
1017+ embed = create_not_found_embed (name , self .bot .aliases .keys (), "Alias" )
1018+ return await ctx .send (embed = embed )
1019+ return await ctx .send (escape_markdown (escape_mentions (val )).replace ("<" , "\\ <" ))
1020+
10141021 @alias .command (name = "add" )
10151022 @checks .has_permissions (PermissionLevel .MODERATOR )
10161023 async def alias_add (self , ctx , name : str .lower , * , value ):
@@ -1027,36 +1034,36 @@ async def alias_add(self, ctx, name: str.lower, *, value):
10271034 - This will fail: `{prefix}alias add reply You'll need to type && to work`
10281035 - Correct method: `{prefix}alias add reply "You'll need to type && to work"`
10291036 """
1037+ embed = None
10301038 if self .bot .get_command (name ):
10311039 embed = Embed (
10321040 title = "Error" ,
10331041 color = Color .red (),
10341042 description = f"A command with the same name already exists: `{ name } `." ,
10351043 )
1036- return await ctx .send (embed = embed )
10371044
1038- if name in self .bot .aliases :
1045+ elif name in self .bot .aliases :
10391046 embed = Embed (
10401047 title = "Error" ,
10411048 color = Color .red (),
10421049 description = f"Another alias with the same name already exists: `{ name } `." ,
10431050 )
1044- return await ctx .send (embed = embed )
10451051
1046- if name in self .bot .snippets :
1052+ elif name in self .bot .snippets :
10471053 embed = Embed (
10481054 title = "Error" ,
10491055 color = Color .red (),
10501056 description = f"A snippet with the same name already exists: `{ name } `." ,
10511057 )
1052- return await ctx .send (embed = embed )
10531058
1054- if len (name ) > 120 :
1059+ elif len (name ) > 120 :
10551060 embed = Embed (
10561061 title = "Error" ,
10571062 color = Color .red (),
10581063 description = f"Alias names cannot be longer than 120 characters." ,
10591064 )
1065+
1066+ if embed is not None :
10601067 return await ctx .send (embed = embed )
10611068
10621069 values = parse_alias (value )
@@ -1106,7 +1113,7 @@ async def alias_add(self, ctx, name: str.lower, *, value):
11061113 return await ctx .send (embed = embed )
11071114 embed .description += f"\n { i } : { val } "
11081115
1109- self .bot .aliases [name ] = "&& " .join (values )
1116+ self .bot .aliases [name ] = " && " .join (values )
11101117 await self .bot .config .update ()
11111118
11121119 return await ctx .send (embed = embed )
@@ -1217,10 +1224,9 @@ async def permissions(self, ctx):
12171224 def _verify_user_or_role (user_or_role ):
12181225 if hasattr (user_or_role , "id" ):
12191226 return user_or_role .id
1220- elif user_or_role in {"everyone" , "all" }:
1227+ if user_or_role in {"everyone" , "all" }:
12211228 return - 1
1222- else :
1223- raise commands .BadArgument (f'User or Role "{ user_or_role } " not found' )
1229+ raise commands .BadArgument (f'User or Role "{ user_or_role } " not found' )
12241230
12251231 @staticmethod
12261232 def _parse_level (name ):
0 commit comments