我的 nextcord (python) 忽略了第一个 if 语句下面的 if 语句,并且无法弄清楚为什么

My nextcord (python) is ignoring the if statements below the first if statement and can't figure out why

抱歉,如果这是一个愚蠢的问题,但是每当我 运行 我的代码时它不听 if 语句中的 if 语句?

@bot.command()
@commands.has_role('Moderator')
async def activity(ctx):
    days = datetime.datetime.now() - datetime.timedelta(days=7)
    print(days)
    for member in ctx.guild.members:
        for role in member.roles:
            if role.name == "Trusted Member":
                if role.name == "Exempt":
                    print("<@" + str(member.id) + "> has a perm exemption")
                elif role.name == "Temp Exempt":
                    print("<@" + str(member.id) + "> has a temp exemption, it has now been removed...")
                else:
                    counter = 0
                    channel = bot.get_channel(1)
                    async for message in channel.history(limit=None, after=days):
                        if message.author == member:
                            counter += 1
                    print("<@" + str(member.id) + "> has sent " + str(counter))

脚本不会检查他们是否具有豁免角色,而是继续检查他们发送了多少消息。

提前致谢。

我在 Rani 的帮助下找到了可行的解决方案

@bot.command()
@commands.has_role('Moderator')
async def activity(ctx):
    days = datetime.datetime.now() - datetime.timedelta(days=7)
    for member in ctx.guild.members:
        role_names = []
        for role in member.roles:
            role_names.append(role.name)
        if "Trusted Member" in role_names:
            if "Exempt" in role_names:
                print("<@" + str(member.id) + "> has a perm exemption")
            elif "Temp Exempt" in role_names:
                print("<@" + str(member.id) + "> has a temp exemption, it has now been removed...")
            else:
                counter = 0
                channel = bot.get_channel(1)
                async for message in channel.history(limit=None, after=days):
                    if message.author == member:
                        counter += 1
                print("<@" + str(member.id) + "> has sent " + str(counter))```