小编Jam*_*ier的帖子

在 repl.it 上运行discord.py bot时如何解决“429:太多请求”?

我的代码(见下文)运行良好,但随后弹出此错误并且不会消失:

"http.py", line 293, in static_login
    data = await self.request(Route('GET', '/users/@me')
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/http.py", line 209, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 429 Too Many Requests (error code: 0): "
Run Code Online (Sandbox Code Playgroud)

我搜索了该错误,发现人们是通过在多台服务器上运行强大的程序,或者人们在一台服务器上运行相同的代码大量次来获得该错误的。但是,我只在一台服务器上运行它,并且代码非常简单。

这是供参考的代码(它在 repl.it 中运行)(os.getenv 用于隐藏机器人的令牌):

import discord
import os

client = discord.Client()

@client.event
async def on_ready():
  print ('We have logged in as {0.user}'.format(client))

@client.event
async def on_message(message):
  if message.author == client.user:
    return
  
  if message.content.startswith('$hello'):
    await message.channel.send('Hello!')

client.run(os.getenv('TOKEN'))
Run Code Online (Sandbox Code Playgroud)

python discord discord.py

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

discord ×1

discord.py ×1

python ×1