How to use the twitchio.commands.errors.TwitchIOCommandError 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.')

            self._aliases[alias] = command.name
github TwitchIO / TwitchIO / twitchio / commands / bot.py View on Github external
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.')

            self._aliases[alias] = command.name
github TwitchIO / TwitchIO / twitchio / commands / bot.py View on Github external
def _init_methods(self):
        commands = inspect.getmembers(self)

        for name, obj in commands:
            if not isinstance(obj, TwitchCommand):
                continue

            obj.instance = self

            try:
                self.add_command(obj)
            except TwitchIOCommandError:
                traceback.print_exc()
                continue
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.')

            self._aliases[alias] = command.name