Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\image.Ai\venv\lib\site-packages\discord\http.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:\Users\User\PycharmProjects\image.Ai\venv\lib\site-packages\discord\http.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\image.Ai\main.py", line 10, in <module>
bot.run(token)
File "C:\Users\User\PycharmProjects\image.Ai\venv\lib\site-packages\discord\client.py", line 723, in run
return future.result()
File "C:\Users\User\PycharmProjects\image.Ai\venv\lib\site-packages\discord\client.py", line 702, in runner
await self.start(*args, **kwargs)
File "C:\Users\User\PycharmProjects\image.Ai\venv\lib\site-packages\discord\client.py", line 665, in start
await self.login(*args, bot=bot)
File "C:\Users\User\PycharmProjects\image.Ai\venv\lib\site-packages\discord\client.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:\Users\User\PycharmProjects\image.Ai\venv\lib\site-packages\discord\http.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001E8E37E73A0>
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
self._check_closed()
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Process finished with exit code 1
Traceback (most recent call last):
class VoiceCommandList:
def __init__(self):
self.actions = list()
def on(self, condition):
if isinstance(condition, list):
conditions = [el.lower() for el in condition]
predicate = lambda text: any(condition in text for condition in conditions)
elif isinstance(condition, str):
condition = condition.lower()
predicate = lambda text: condition in text
if isinstance(condition, str):
condition = condition.lower()
predicate = lambda text: condition in text
elif callable(condition):
predicate = condition
else:
raise TypeError('Condition must be either string or function!')
def decorator(command_func):
self.actions.append((predicate, command_func))
return command_func
return decorator
def run_command(self, text):
text = text.lower()
for predicate, command in self.actions:
if predicate(text):
try:
response = command(text)
if response is None:
response = "Команда выполнена"
except Exception as err:
response = "Ошибка при выполнении команды"
print(err)
if response:
say_message(response)
break
else:
say_message("Неизвестная команда")
vcl = VoiceCommandList()
@vcl.on(lambda text: ('Новая страница' in text) or ('Открой новую страницу' in text))
def new_webpage(text):
new_page()
return "Страница открыта"