为什么我的 discord bot 不能使用 python 和 Discord API 上线?

时间:2021-05-13 14:47:35

标签: python discord

我按照教程 (https://www.youtube.com/watch?v=XTdaaFIHpeI&list=PLJXEdhN0Tc3LRT716enS1LcY4OF8vg1VA&index=2) 制作了一个不和谐的机器人,但是我无法让它上​​线。除了终端中的运行时错误(附在下面)之外,我没有收到任何错误。 我已经在许多网站和视频上寻找解决方案,但仍然没有成功。

这是教程中的python代码:

import discord
client = discord.Client()
client.run('discord token')

终端输出:

c:/Users/(**username**)/Desktop/Text_Adventure_Bot/Text_Adventure_Bot.py 
Traceback (most recent call last):
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\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\(**username**)\Desktop\Text_Adventure_Bot\Text_Adventure_Bot.py", line 4, in <module>
    client.run('discord token')
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 723, in run       
    return future.result()
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\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 0x000001E3AEC5FDC0>
Traceback (most recent call last):
  File "C:\Users\(**username**)\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Users\(**username**)\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\(**username**)\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Users\(**username**)\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

0 个答案:

没有答案