通过检查用户角色,错误在哪里?

2024-04-28 21:44:27 发布

您现在位置:Python中文网/ 问答频道 /正文

守则:

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    Besucher = message.guild.get_role(718944429888766044)
    Neuling = message.guild.get_role(721440088248025179)
    
    if message.content.startswith("!verify"):
        if  message.author.role == Neuling:
            await message.author.add_roles(Besucher)
            await message.author.remove_roles(Neuling)
            await message.author.send("Du wurdest Verifiziert")
            await message.delete() 
        else:
            await message.author.send("Du wurdest bereits verifiziert")

错误:

File "Discord.py", line 23, in on_message
    if message.author.role == Neuling:
AttributeError: 'Member' object has no attribute 'role'

我需要检查用户的角色,因为message.author.role==Neuling不是吗

谢谢你的回答


Tags: clientsendmessagegetifonawaitrole