Python 如何在discord.py中的on_ready事件中向成员添加角色?
我一直在尝试在on_ready命令中添加角色Python 如何在discord.py中的on_ready事件中向成员添加角色?,python,discord,discord.py,Python,Discord,Discord.py,我一直在尝试在on_ready命令中添加角色 @client.event async def on_ready(): with open('roles.json','r') as f: rolesjson = json.load(f) game = discord.Game(name=",help") await client.change_presence(status=discord.Status.idle, activity=game) pr
@client.event
async def on_ready():
with open('roles.json','r') as f:
rolesjson = json.load(f)
game = discord.Game(name=",help")
await client.change_presence(status=discord.Status.idle, activity=game)
print('Logged in!')
for m in client.get_all_members():
if f'{m.id}' in rolesjson:
if rolesjson[f'{m.id}']['time'] != 0:
await asyncio.sleep(rolesjson[f'{m.id}']['time'])
RemoveRole = discord.utils.get(m.guild.roles, name='Silenced')
await m.remove_roles(RemoveRole)
# roless = [discord.utils.get(m.guild.roles, name=n) for n in rolesjson[f'{m.id}']['roles'] if
n != '@everyone']
# await m.add_roles(*roless)
rolesjson[f'{m.id}']['time'] = 0
with open('roles.json','w') as f:
json.dump(rolesjson,f)
但这并没有完全消除这个角色。我也没有得到任何类型的错误。那么,如何删除on_ready事件中的角色?请显示错误