48
48
from core .changelog import Changelog
49
49
from core .clients import DatabaseClient , PluginDatabaseClient
50
50
from core .config import ConfigManager
51
- from core .utils import info , error
51
+ from core .utils import info , error , human_join
52
52
from core .models import Bot , PermissionLevel
53
53
from core .thread import ThreadManager
54
54
from core .time import human_timedelta
@@ -167,8 +167,6 @@ async def get_prefix(self, message=None):
167
167
168
168
def _load_extensions (self ):
169
169
"""Adds commands automatically"""
170
- self .remove_command ('help' )
171
-
172
170
logger .info (LINE )
173
171
logger .info (info ('┌┬┐┌─┐┌┬┐┌┬┐┌─┐┬┬' ))
174
172
logger .info (info ('││││ │ │││││├─┤││' ))
@@ -834,13 +832,6 @@ async def on_error(self, event_method, *args, **kwargs):
834
832
logger .error (error ('Unexpected exception:' ), exc_info = sys .exc_info ())
835
833
836
834
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
-
844
835
if isinstance (exception , commands .BadUnionArgument ):
845
836
msg = 'Could not find the specified ' + human_join ([c .__name__ for c in exception .converters ])
846
837
await ctx .trigger_typing ()
@@ -855,12 +846,17 @@ def human_join(strings):
855
846
color = discord .Color .red (),
856
847
description = str (exception )
857
848
))
858
- elif isinstance (exception , commands .MissingRequiredArgument ):
859
- await ctx .invoke (self .get_command ('help' ),
860
- command = str (ctx .command ))
861
849
elif isinstance (exception , commands .CommandNotFound ):
862
850
logger .warning (error ('CommandNotFound: ' + str (exception )))
851
+ elif isinstance (exception , commands .MissingRequiredArgument ):
852
+ await ctx .send_help (ctx .command )
863
853
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
+ ))
864
860
logger .warning (error ('CheckFailure: ' + str (exception )))
865
861
else :
866
862
logger .error (error ('Unexpected exception:' ), exc_info = exception )
@@ -975,9 +971,5 @@ async def metadata_loop(self):
975
971
976
972
977
973
if __name__ == '__main__' :
978
- if os .name != 'nt' :
979
- import uvloop
980
-
981
- uvloop .install ()
982
974
bot = ModmailBot ()
983
975
bot .run ()
0 commit comments