How to use the twitchio.commands.core.TwitchCommand function in twitchio

To help you get started, we’ve selected a few twitchio examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TwitchIO / TwitchIO / twitchio / commands / bot.py View on Github external
def add_command(self, command):
        if not isinstance(command, TwitchCommand):
            raise TypeError('Commands passed my be a subclass of TwitchCommand.')
        elif command.name in self.commands:
            raise TwitchIOCommandError(f'Failed to load command <{command.name}>, a command with that name already exists')
        elif not inspect.iscoroutinefunction(command._callback):
            raise TwitchIOCommandError(f'Failed to load command <{command.name}>. Commands must be coroutines.')

        self.commands[command.name] = command

        if not command.aliases:
            return

        for alias in command.aliases:
            if alias in self.commands:
                del self.commands[command.name]
                raise TwitchIOCommandError(
                    f'Failed to load command <{command.name}>, a command with that name/alias already exists.')