坐下来学习有关discord.py 0.16.12的信息我对函数discord.Client.edit_role(server,role,parametrs *)感兴趣 我遇到了一个问题(一切正常前一个小时)
Ignoring exception in on_ready
Traceback (most recent call last):
File "C:\Users\ROG\Desktop\trash\dsbt\venv\lib\site-packages\discord\client.py", line 307, in _run_event
yield from getattr(self, event)(*args, **kwargs)
File "C:/Users/ROG/Desktop/trash/dsbt/rainbown_rolle/testbd.py", line 10, in on_ready
await bot.edit_role(sr, rl, colour=discord.Colour(((rgb[0] << 16) + (rgb[1] << 8) + rgb[2])))
File "C:\Users\ROG\Desktop\trash\dsbt\venv\lib\site-packages\discord\client.py", line 2860, in edit_role
yield from self.http.edit_role(server.id, role.id, **payload)
File "C:\Users\ROG\Desktop\trash\dsbt\venv\lib\site-packages\discord\http.py", line 169, in request
print(data['retry_after'])
TypeError: string indices must be integers
批号
import discord
token="token"
bot=discord.Client()
@bot.event
async def on_ready():
rgb = [255, 0, 161]
sr= discord.utils.find(lambda m: m.id == '403945874780061707',bot.servers)
rl = discord.utils.find(lambda m: m.name == "Обыватель", sr.roles)
print(type(sr),type(rl))
await bot.edit_role(sr, rl, colour=discord.Colour(((rgb[0] << 16) + (rgb[1] << 8) + rgb[2])))
bot.run(token)
答案 0 :(得分:0)
看起来端点返回了一些响应主体,它只是文本,而不是json。
discord.py期望状态为429(受速率限制)的响应是一个json,它可以变成字典。因此,它试图像字典一样访问文本,但失败了。
根据this commit(此问题为rewrite分支解决了此问题),可能是Cloudflare禁止了您。尝试将您的漫游器更新到新版本,但是您很可能必须将漫游器托管在其他地方才能解决它们已实施的所有禁令。