根据角色ID授予角色

时间:2019-05-17 21:22:24

标签: discord.py discord.py-rewrite

我试图在行会中将基于角色ID的角色提供给行会中的用户,但是,当我提供角色ID和提供角色名称时,我似乎无法将其提供给我。 / p>

我都尝试过

@Nao.event
async def on_member_join(member):
    database = mysql.connector.connect(
        host='localhost',
        user='root',
        passwd='',
        database='Nao'
    )
    cursor = database.cursor()
    query = "SELECT role FROM autorole WHERE server = %s"
    values = (member.guild.id,)
    cursor.execute(query, values)
    result = cursor.fetchall()
    for role in result:
        role = discord.utils.get(member.guild.roles, name='Members')
        await member.add_roles(role)

哪些作品和

@Nao.event
async def on_member_join(member):
    database = mysql.connector.connect(
        host='localhost',
        user='root',
        passwd='',
        database='Nao'
    )
    cursor = database.cursor()
    query = "SELECT role FROM autorole WHERE server = %s"
    values = (member.guild.id,)
    cursor.execute(query, values)
    result = cursor.fetchall()
    for role in result:
        role = discord.utils.get(member.guild.roles, id=role[0])
        await member.add_roles(role)

不起作用,并给我错误;

  

等待请求(guild_id,user_id,role.id,原因=原因)AttributeError:'NoneType'对象没有属性'id'

0 个答案:

没有答案