client.run超时(discord.py)

时间:2020-06-07 14:05:13

标签: client discord.py

我正在使用

import discord
client=discord.Client()

@client.event
async def on_ready():
    print('WE have logged in')


client.run('my token goes here')

但是问题不在于脚本。因为几天前它运行良好,所以我可以轻松地连接到我的机器人并执行操作。但是今天我把它踢了出来,然后又重新添加了,从那以后就不起作用了。

这里我做了

-我从discord开发人员门户网站添加了Outh2访问权限,方法是复制一个url并转到那里 -复制当前令牌并使用 -重新授权/将其添加到我的服务器(我知道我不应该这样做)

  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语句内部,当我刚开始时,我也遇到了相同的timout错误,但我不记得它是如何解决的。 我更改了名称并在一段时间后尝试了该方法,但这种方法确实有效,在这种情况下,我确实尝试过,但没有成功。

也许我做错了完全不同的事情。

1 个答案:

答案 0 :(得分:0)

嗯...您有点需要前缀。将client=discord.Client()替换为client = commands.Bot(command_prefix=['Prefix goes here'])