General Cleanup and changed visibility of methods.
This commit is contained in:
parent
7f60f4dee6
commit
22b5ddfe91
@ -19,7 +19,7 @@ class Command:
|
|||||||
return words
|
return words
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getCommand(string):
|
def __getCommand(string):
|
||||||
words = Command.__getWords(string);
|
words = Command.__getWords(string);
|
||||||
if len(words) == 0: return
|
if len(words) == 0: return
|
||||||
if words[0].startswith(Command.command_prefix):
|
if words[0].startswith(Command.command_prefix):
|
||||||
@ -27,20 +27,21 @@ class Command:
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getArgs(string):
|
def __getArgs(string):
|
||||||
words = Command.__getWords(string);
|
words = Command.__getWords(string);
|
||||||
return words[1:]
|
return words[1:]
|
||||||
|
|
||||||
|
# Add a command
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def registerCallback(command, callback):
|
def registerCallback(command, callback):
|
||||||
Command.__callbacks[command] = callback
|
Command.__callbacks[command] = callback
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def call(channel, command):
|
async def call(channel, command):
|
||||||
func = Command.__callbacks.get(Command.getCommand(command), None)
|
func = Command.__callbacks.get(Command.__getCommand(command), None)
|
||||||
if func is not None:
|
if func is not None:
|
||||||
try:
|
try:
|
||||||
await func(channel, *tuple(Command.getArgs(command)))
|
await func(channel, *tuple(Command.__getArgs(command)))
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
print(e)
|
print(e)
|
||||||
await channel.send("Incorrect usage.")
|
await channel.send("Incorrect usage.")
|
||||||
|
Loading…
Reference in New Issue
Block a user