Python discord.py:将所有角色从公会添加到用户

Python discord.py:将所有角色从公会添加到用户,python,discord.py,Python,Discord.py,我想将所有角色从公会添加到用户。但我不知道怎么做 我现在的代码: @client.command() async def addrole(ctx, member: discord.Member): roles = get(member.guild.roles) if ctx.message.author.guild_permissions.administrator: await member.edit(roles=[roles]) await

我想将所有角色从公会添加到用户。但我不知道怎么做

我现在的代码:

@client.command()
async def addrole(ctx, member: discord.Member):
    roles = get(member.guild.roles)

    if ctx.message.author.guild_permissions.administrator:
        await member.edit(roles=[roles])
        await ctx.send(f'Alle Rollen des Servers {member.mention} hinzugefügt!')
    else:
        await ctx.send('Du hast keine Berechtigung!')
我知道,我可以用
add_roles
来实现这一点,但我希望用户的所有角色都被所有公会角色替换。

如果使用
add_roles()
,用户已经拥有的任何角色都将被忽略,他们没有的所有角色都将被添加:

@client.command()
异步def addroles(ctx,成员:discord.member):
对于ctx.guild.roles中的r:
try:#如果bot没有足够的perm赋予角色,则会出错
等待ctx.author.add_角色(r)
除:
打印(f“{r.name}无法提供给{member}”)
wait ctx.send(f“成功地为{member}提供了我所能提供的所有角色!”)

参考文献: