1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Add commands list

This commit is contained in:
Steffo 2020-07-18 03:11:28 +02:00
parent 28e98cef31
commit 4948302324
Signed by: steffo
GPG key ID: 896A80F55F7C97F0

View file

@ -11,17 +11,27 @@ class HelpCommand(rc.Command):
syntax: str = "{comando}" syntax: str = "{comando}"
async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None:
name: str = args[0].lstrip(self.interface.prefix) if len(args) == 0:
message = [
" Comandi disponibili:"
]
try: for command in sorted(list(set(self.serf.commands.values())), key=lambda c: c.name):
command: rc.Command = self.serf.commands[f"{self.interface.prefix}{name}"] message.append(f"- [c]{self.interface.prefix}{command.name}[/c]")
except KeyError:
raise rc.InvalidInputError("Il comando richiesto non esiste.")
message = [ await data.reply("\n".join(message))
f"[c]{self.interface.prefix}{command.name} {command.syntax}[/c]", else:
"", name: str = args[0].lstrip(self.interface.prefix)
f"{command.description}"
]
await data.reply("\n".join(message)) try:
command: rc.Command = self.serf.commands[f"{self.interface.prefix}{name}"]
except KeyError:
raise rc.InvalidInputError("Il comando richiesto non esiste.")
message = [
f" [c]{self.interface.prefix}{command.name} {command.syntax}[/c]",
"",
f"{command.description}"
]
await data.reply("\n".join(message))