【发布时间】:2018-10-04 18:59:35
【问题描述】:
我有一个用于 Fortnite KD 排名自动权限的机器人。它的工作原理是;
如果用户有 1+ KD 机器人将分配用户“青铜”perm。
如果用户有 1.5+ KD 机器人将分配用户“Gümüş”perm。
如果用户有 2+ KD 机器人将分配用户“Altın”perm。
它就像一个魅力。但。 Bot 在下一个 perm 排名时必须删除旧角色。所以我的意思是,如果用户对“Altın”烫发进行排名。旧烫发“Gümüş”必须删除,但remove.roles 不起作用。
下面是这些行的一堆代码:
for list in LISTE:
roles = discord.utils.get(message.server.roles, name=list)
await client.remove_roles(message.author, role)
await client.add_roles(message.author, role)
elif ratio >= BRONZE_B and ratio <= BRONZE_E:
role = discord.utils.get(message.server.roles, name=LISTE[2])
embed=discord.Embed(color=0xcd8032)
embed.add_field(name="Oyuncu", value=username, inline=True)
embed.add_field(name="KD", value=str(ratio), inline=True)
embed.add_field(name="Lig", value=LISTE[2], inline=True)
await client.send_message(message.channel, embed = embed)
embed2=discord.Embed(color=0x727272)
embed2.add_field(name="Sonraki Lig", value=LISTE[3], inline=True)
embed2.add_field(name="Hedef KD", value=str(SILVER_B), inline=True)
embed2.set_footer(text="Lig verileriniz Fortnite KD değerlerinize göre güncellendi.")
await client.send_message(message.channel, embed = embed2)
for list in LISTE:
roles = discord.utils.get(message.server.roles, name=list)
await client.remove_roles(message.author, role)
await client.add_roles(message.author, role)
elif ratio >= SILVER_B and ratio <= SILVER_E:
role = discord.utils.get(message.server.roles, name=LISTE[3])
embed=discord.Embed(color=0x727272)
embed.add_field(name="Oyuncu", value=username, inline=True)
embed.add_field(name="KD", value=str(ratio), inline=True)
embed.add_field(name="Lig", value=LISTE[3], inline=True)
await client.send_message(message.channel, embed = embed)
embed2=discord.Embed(color=0xcfb223)
embed2.add_field(name="Sonraki Lig", value=LISTE[4], inline=True)
embed2.add_field(name="Hedef KD", value=str(GOLD_B), inline=True)
embed2.set_footer(text="Lig verileriniz Fortnite KD değerlerinize göre güncellendi.")
await client.send_message(message.channel, embed = embed2)
如果我使用 replace_roles 而不是 remove_roles 它似乎可以工作,但这次它会删除所有角色并将其替换为更高级别的权限。
我的意思是,当我使用 replace_roles 时,如果主持人使用我的机器人命令 /derece 检查他的等级,机器人会承担他的所有角色并给予他更高的 KD 等级权限。
我希望它像这样工作;
如果用户有 1+ KD 机器人将分配用户“青铜”perm。
如果用户排名高达 1.5+ KD,则删除
Bronz烫发并给予Silver烫发如果用户排名达到 2+ KD,则删除
Silverperm 并给出Goldperm
谢谢。
【问题讨论】:
标签: python python-3.x python-requests discord discord.py