我试图执行一个addrole命令,但是它没有用。我的意思是当角色不在角色列表中时(如果abc / else中的角色),它不起作用,我不知道为什么请帮助。
@client.command()
async def addrole(ctx, user: discord.Member, role: discord.Role):
if ctx.author.guild_permissions.administrator:
abc = ctx.guild.roles
xx = user.roles
if role in abc:
if role not in xx:
await user.add_roles(role)
await ctx.send(f'{user.mention}, {role} Verildi')
else:
await ctx.send(f'The User already have the role)
else:
await ctx.send(f'The role you are looking for is not in the server')
else:
await ctx.send(f'You Have not enough permissions to run this command')
答案 0 :(得分:0)
查看角色是否存在的更简单方法是使用cv2.compareHist(histr_hx, txtHist.astype(histr_hx.dtype), cv2.HISTCMP_CORREL)
discord.Utils.get
如果具有所述名称的角色不存在,则返回discord.Utils.get(ctx.guild.roles, name="Role-Name")
。