1
1
from discord .ext import commands
2
2
import secrets
3
-
3
+ import traceback
4
4
from datetime import datetime
5
5
6
6
description = '''An example arbot to showcase the discord.ext.commands extension
@@ -19,6 +19,17 @@ async def on_ready():
19
19
print (arbot .user .name )
20
20
print ('Servers: ' + ', ' .join ([str (s ) for s in arbot .servers ]))
21
21
print ('------' )
22
+
23
+ @arbot .event
24
+ async def on_command (s ,e ):
25
+ print ("{0.name} used >{1} in {2.name} (Channel #{3})" .format (e .message .author ,s ,e .message .server ,e .message .channel ))
26
+
27
+ @arbot .event
28
+ async def on_command_error (error ,ctx ):
29
+ em = discord .Embed (title = "An Error occured" ,description = "Sorry but I couldn't process that command properely" ,color = discord .Color .red ())
30
+ await bot .send_message (ctx .message .channel ,embed = em )
31
+ tb = "\n " .join (traceback .format_tb (error .original .__traceback__ ))
32
+ print ("{}: {}\n {}" .format (error .original .__class__ .__name__ ,str (error ),str (tb )))
22
33
23
34
@arbot .command ()
24
35
async def load (extension_name : str ):
@@ -62,4 +73,4 @@ async def ti():
62
73
exc = '{}: {}' .format (type (e ).__name__ , e )
63
74
print ('Failed to load extension {}\n {}' .format (extension , exc ))
64
75
65
- arbot .run (secrets .BOT_TOKEN )
76
+ arbot .run (secrets .BOT_TOKEN )
0 commit comments