AttributeError:'Bot'对象没有属性'add_roles'

我正在用Python写一个不和谐的机器人。我希望当有人登录服务器时,赋予他特定角色

import docx
from docx.enum.text import WD_PARAGRAPH_ALIGnmENT
from docx.shared import Inches,Cm,Mm
import lorem

new_document = docx.Document()



table = new_document.add_table(rows=1,cols=2)

pic_cel = table.rows[0].cells[0].add_paragraph()
run = pic_cel.add_run()
run.add_picture("Image.jpg",width = Mm(45),height = Mm(45))

text = table.rows[0].cells
text[0].width = Inches(50)
text[1].text = 'kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'
new_document.save("test.docx")

当我启动并且有人进入服务器时,出现以下错误: AttributeError:'Bot'对象没有属性'add_roles'

chkxchkx 回答:AttributeError:'Bot'对象没有属性'add_roles'

确保您使用的是latest version of the documentation。您应该从公会获得该角色,并使用Member.add_roles

@bot.event
async def on_member_join(member):
    role = get(member.guild.roles,name="Игроки")
    await member.add_roles(role)
本文链接:https://www.f2er.com/3028601.html

大家都在问