所以我有一个Discord服务器,我希望我的机器人在其中将状态为discord.gg/chilling的每个人赋予特定角色!
它还将持续检查每分钟左右,以查看用户是否具有该状态或已将其删除!
这是我到目前为止所拥有的...
@client.command()
async def rolev(ctx):
role_added = 0
role_removed = 0
memcount = 0
guild = client.get_guild(763626880775225384)
role = discord.utils.get(guild.roles, name="I Am Sexier")
for member in guild.members:
if member.activity is None:
pass
elif 'discord.gg/chilling' == member.activity.name:
await member.add_roles(role)
role_added +=1
else:
await member.remove_roles(role)
role_removed += 1
memcount += 1
await ctx.send(f"**Done -> Added The Role For: `{role_added}` | Removed The Role From -> `{role_removed}` | Checked -> `{memcount}`**")
这是我得到的错误:
await member.remove_roles(role)
File "D:\Python\lib\site-packages\discord\member.py", line 685, in remove_roles
await req(guild_id, user_id, role.id, reason=reason)
AttributeError: 'NoneType' object has no attribute 'id'
我该怎么办?
IK yall是一群天才,所以我希望我能从这里得到答案...