@@ -466,11 +466,13 @@ def parse_command(self, command):
466
466
class CommandInfo (object ):
467
467
"""Stores command information for typed commands."""
468
468
469
- def __init__ (self , command , index = None , team_only = None ):
469
+ def __init__ (self , command , typed_command_cls , index = None , team_only = None ):
470
470
"""Initializes the instance.
471
471
472
472
:param Command command:
473
473
The actual Command instance.
474
+ :param _TypedCommand typed_command_cls:
475
+ Command this instance belongs to.
474
476
:param int index:
475
477
The index of the player that issued the command. None, if it's a
476
478
server command.
@@ -479,9 +481,18 @@ def __init__(self, command, index=None, team_only=None):
479
481
it's a server or client command.
480
482
"""
481
483
self .command = command
484
+ self .typed_command_cls = typed_command_cls
482
485
self .index = index
483
486
self .team_only = team_only
484
487
488
+ def reply (self , msg ):
489
+ """Reply to the command issuer.
490
+
491
+ :param str msg:
492
+ Message to send.
493
+ """
494
+ self .typed_command_cls .send_message (self , msg )
495
+
485
496
486
497
# We can't integrate this into SayCommand, ServerCommand and ClientCommand,
487
498
# because multiple callbacks are not supported by this system (because of the
@@ -547,13 +558,13 @@ def on_command(cls, command, *args):
547
558
Parse the command, clean its arguments and execute the callback.
548
559
"""
549
560
# TODO: Translations!
550
- command_info = CommandInfo (command , * args )
561
+ command_info = CommandInfo (command , cls , * args )
551
562
try :
552
563
command_node , args = cls .parser .parse_command (
553
564
command_info .command )
554
565
result = cls .on_clean_command (command_info , command_node , args )
555
566
except ValidationError as e :
556
- cls . send_message ( command_info , e .message )
567
+ command_info . reply ( e .message )
557
568
else :
558
569
return result
559
570
0 commit comments