88from textwrap import indent
99
1010import discord
11- from aiohttp import ClientResponseError
1211from discord import Embed , Color , Activity
1312from discord .enums import ActivityType
1413from discord .ext import commands
1514
15+ from aiohttp import ClientResponseError
16+
1617from core import checks
1718from core .changelog import Changelog
1819from core .decorators import github_access_token_required , trigger_typing
@@ -27,13 +28,15 @@ class Utility:
2728 def __init__ (self , bot : Bot ):
2829 self .bot = bot
2930
30- async def check_checks (self , ctx , cmd ):
31+ @staticmethod
32+ async def verify_checks (ctx , cmd ):
3133 predicates = cmd .checks
3234 if not predicates :
3335 return True
3436
3537 try :
36- return await discord .utils .async_all (predicate (ctx ) for predicate in predicates )
38+ return await discord .utils .async_all (predicate (ctx )
39+ for predicate in predicates )
3740 except commands .CheckFailure :
3841 return False
3942
@@ -45,7 +48,8 @@ async def format_cog_help(self, ctx, cog):
4548 fmts = ['' ]
4649 for cmd in sorted (self .bot .commands ,
4750 key = lambda cmd : cmd .qualified_name ):
48- if cmd .instance is cog and not cmd .hidden and await self .check_checks (ctx , cmd ):
51+ if cmd .instance is cog and not cmd .hidden and \
52+ await self .verify_checks (ctx , cmd ):
4953 new_fmt = f'`{ prefix + cmd .qualified_name } ` - '
5054 new_fmt += f'{ cmd .short_doc } \n '
5155 if len (new_fmt ) + len (fmts [- 1 ]) >= 1024 :
@@ -58,7 +62,8 @@ async def format_cog_help(self, ctx, cog):
5862 if fmt == '' :
5963 continue
6064 embed = Embed (
61- description = '*' + (inspect .getdoc (cog ) or 'No description' ) + '*' ,
65+ description = '*' + (inspect .getdoc (cog ) or
66+ 'No description' ) + '*' ,
6267 color = self .bot .main_color
6368 )
6469
@@ -73,7 +78,7 @@ async def format_cog_help(self, ctx, cog):
7378
7479 async def format_command_help (self , ctx , cmd ):
7580 """Formats command help."""
76- if cmd .hidden or not await self .check_checks (ctx , cmd ):
81+ if cmd .hidden or not await self .verify_checks (ctx , cmd ):
7782 return None
7883
7984 prefix = self .bot .prefix
@@ -117,13 +122,14 @@ async def format_not_found(self, ctx, command):
117122 # filter out hidden commands & blank cogs
118123 for i in self .bot .cogs :
119124 for cmd in self .bot .commands :
120- if cmd .cog_name == i and not cmd .hidden and await self .check_checks (ctx , cmd ):
125+ if cmd .cog_name == i and not cmd .hidden and \
126+ await self .verify_checks (ctx , cmd ):
121127 # as long as there's one valid cmd, add cog
122128 choices .add (i )
123129 break
124130
125131 for i in self .bot .commands :
126- if not i .hidden and await self .check_checks (ctx , i ):
132+ if not i .hidden and await self .verify_checks (ctx , i ):
127133 choices .add (i .name )
128134
129135 closest = get_close_matches (command , choices , n = 1 , cutoff = 0.45 )
0 commit comments