Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.')