我正在使用
import discord
client=discord.Client()
@client.event
async def on_ready():
print('WE have logged in')
client.run('my token goes here')
但问题不在于脚本。因为几天前,它工作得很好,我可以很容易地连接到我的机器人和做一些事情。但今天我把它踢出去,又把它加进去,从那时起,它就不能工作了。
下面是我做了什么
我从discord开发门户中添加了Outh2的访问权限,通过复制一个网址并去那里--复制当前的令牌并使用它--授权将其再次添加到我的服务器上(我知道我不应该做这个)。
File "/home/soutrik/.local/lib/python3.8/site-packages/discord/client.py", line 640, in run
return future.result()
File "/home/soutrik/.local/lib/python3.8/site-packages/discord/client.py", line 621, in runner
await self.start(*args, **kwargs)
File "/home/soutrik/.local/lib/python3.8/site-packages/discord/client.py", line 584, in start
await self.login(*args, bot=bot)
File "/home/soutrik/.local/lib/python3.8/site-packages/discord/client.py", line 442, in login
await self.http.static_login(token.strip(), bot=bot)
File "/home/soutrik/.local/lib/python3.8/site-packages/discord/http.py", line 261, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/soutrik/.local/lib/python3.8/site-packages/discord/http.py", line 165, in request
async with self.__session.request(method, url, **kwargs) as r:
File "/home/soutrik/.local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
self._resp = await self._coro
File "/home/soutrik/.local/lib/python3.8/site-packages/aiohttp/client.py", line 582, in _request
break
File "/home/soutrik/.local/lib/python3.8/site-packages/aiohttp/helpers.py", line 596, in __exit__
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
错在client.run语句里面,当我第一次开始的时候,我也面临着这个同样的超时错误,但我不记得它是怎么解决的了,我改了名字,并在一段时间后试了一下,它就成功了,在这种情况下,我确实尝试了,但它没有工作。
也许我做了一些完全不同的错误的事情。
嗯... 你需要一个前缀。替换为 client=discord.Client()
与 client = commands.Bot(command_prefix=['Prefix goes here'])