"""Alias command."""

from . import Command


class Alias(Command):
    """Alias command."""

    COMMAND = "alias"

    @Command.command(role="moderator")
    async def add(self, alias: "?command", command: "?command", *args: False,
                  raw: "packet"):
        """Add a new command alias."""

        _, _, _, packet_args = raw.split(maximum=3)

        response = await self.api.add_alias(command, alias, packet_args.json)

        if response.status == 201:
            return "Alias {} for command {} created.".format(alias, command)
        elif response.status == 200:
            return "Alias {} for command {} updated.".format(alias, command)

    @Command.command(role="moderator")
    async def remove(self, alias: "?command"):
        """Remove a command alias."""

        response = await self.api.remove_alias(alias)
        if response.status == 200:
            return "Alias {} removed.".format(alias)
        elif response.status == 404:
            return "Alias {} doesn't exist!".format(alias)

@@ -317,16 +317,19 @@
 _, _, _,
+ _,
  packet_
@@ -357,9 +357,9 @@
 mum=
-3
+4
 )%0A%0A 
@@ -1010,24 +1010,623 @@
 t exist!%22.format(alias)%0A
+%0A    @Command.command(%22list%22, role=%22moderator%22)%0A    async def list_aliases(self):%0A        %22%22%22List all aliases.%22%22%22%0A        response = await self.api.get_command()%0A%0A        if response.status == 200:%0A            commands = (await response.json())%5B%22data%22%5D%0A            return %22Commands: %7B%7D%22.format(', '.join(sorted(%0A                %22%7B%7D (%7B%7D)%22.format(%0A                    command%5B%22attributes%22%5D%5B%22name%22%5D,%0A                    command%5B%22attributes%22%5D%5B%22commandName%22%5D)%0A                for command in commands%0A                if command.get(%22type%22) == %22aliases%22%0A            )))%0A        return %22No commands added!%22%0A

Add !alias list, fix alias argument storage