【发布时间】:2022-03-07 20:11:53
【问题描述】:
我真的是编程新手,因此决定观看教程以了解如何使用 Python 创建 Discord 机器人。
本教程进行得很顺利,但随后弹出此错误,我似乎无法找到摆脱它的方法:
"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): "
我搜索了这个错误,我发现人们是通过在多台服务器上运行强大的程序得到它,或者人们在一台服务器上运行相同的代码吨次。但是,我只在一台服务器上运行它,而且代码非常简单。
这是参考代码(它在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'))
【问题讨论】:
标签: python discord discord.py