Managing Status

Registering a command handler with a decorator and taking effect is cool, but it’s not always the case. Sometimes you may want to disable a command temporarily, or dynamically, without changing the source code. That’s when command status management becomes handy.

Closing and Opening Commands

Given a command greet

@mgr.command
def greet():
    return "Hello!"

To disable or close it, just call

mgr.close("greet")

When attempting to execute a closed command, the comamnd handler will not be called, and the execution just returns Config.text_command_closed.

>>> mgr.exec("greet")
'Sorry, this command is currently disabled.'

Note

Pass the name to CommandsManager.close(), not the command handler function.