【发布时间】:2021-06-27 12:26:33
【问题描述】:
如果成员加入on_member_join event,我正在尝试添加角色
我的代码是这样的
@client.event
async def on_member_join(member):
gu_id = int(member.guild.id)
a = gu.find_one({"_id": gu_id}) # I use mongodb and find the guild
role_name = str(a['role'])
role = member.guild.get_role(role_name)
print(role_name)
await member.add_roles(role)
但我总是得到这个错误
AttributeError: 'NoneType' 对象没有属性 'id'
我也用角色 id 尝试过这个,但是我得到了这个错误
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions
【问题讨论】:
标签: python python-3.x mongodb discord discord.py