4848from core .changelog import Changelog
4949from core .clients import DatabaseClient , PluginDatabaseClient
5050from core .config import ConfigManager
51- from core .utils import info , error
51+ from core .utils import info , error , human_join
5252from core .models import Bot , PermissionLevel
5353from core .thread import ThreadManager
5454from core .time import human_timedelta
@@ -167,8 +167,6 @@ async def get_prefix(self, message=None):
167167
168168 def _load_extensions (self ):
169169 """Adds commands automatically"""
170- self .remove_command ('help' )
171-
172170 logger .info (LINE )
173171 logger .info (info ('┌┬┐┌─┐┌┬┐┌┬┐┌─┐┬┬' ))
174172 logger .info (info ('││││ │ │││││├─┤││' ))
@@ -834,13 +832,6 @@ async def on_error(self, event_method, *args, **kwargs):
834832 logger .error (error ('Unexpected exception:' ), exc_info = sys .exc_info ())
835833
836834 async def on_command_error (self , ctx , exception ):
837-
838- def human_join (strings ):
839- if len (strings ) <= 2 :
840- return ' or ' .join (strings )
841- else :
842- return ', ' .join (strings [:len (strings )- 1 ]) + ' or ' + strings [- 1 ]
843-
844835 if isinstance (exception , commands .BadUnionArgument ):
845836 msg = 'Could not find the specified ' + human_join ([c .__name__ for c in exception .converters ])
846837 await ctx .trigger_typing ()
@@ -855,12 +846,17 @@ def human_join(strings):
855846 color = discord .Color .red (),
856847 description = str (exception )
857848 ))
858- elif isinstance (exception , commands .MissingRequiredArgument ):
859- await ctx .invoke (self .get_command ('help' ),
860- command = str (ctx .command ))
861849 elif isinstance (exception , commands .CommandNotFound ):
862850 logger .warning (error ('CommandNotFound: ' + str (exception )))
851+ elif isinstance (exception , commands .MissingRequiredArgument ):
852+ await ctx .send_help (ctx .command )
863853 elif isinstance (exception , commands .CheckFailure ):
854+ for check in ctx .command .checks :
855+ if not await check (ctx ) and hasattr (check , 'fail_msg' ):
856+ await ctx .send (embed = discord .Embed (
857+ color = discord .Color .red (),
858+ description = check .fail_msg
859+ ))
864860 logger .warning (error ('CheckFailure: ' + str (exception )))
865861 else :
866862 logger .error (error ('Unexpected exception:' ), exc_info = exception )
@@ -975,9 +971,5 @@ async def metadata_loop(self):
975971
976972
977973if __name__ == '__main__' :
978- if os .name != 'nt' :
979- import uvloop
980-
981- uvloop .install ()
982974 bot = ModmailBot ()
983975 bot .run ()
0 commit comments