【发布时间】:2018-05-04 22:14:03
【问题描述】:
您好,我正在努力研究如何防止成员通过使用角色来获取其他成员的头像,因为您可以看到拥有私人头像角色的成员将保护他们的头像。这就是我在 .py 中编码的方式
class Avatar:
"""Returns members avatar."""
def __init__(self, bot):
self.bot = bot
@commands.command(pass_context=True)
@commands.cooldown(5, 60, commands.BucketType.user)
async def avatar(self, context, member: discord.Member):
"""Returns members avatar."""
role = discord.utils.get(member.server.roles, name="Private Avatar")
author = context.message.author.mention
mention = member.mention
if role in member.roles:
pa = "This members avatar is private"
await self.bot.say(pa)
return
avatar = "{0} here is {1}'s avatar"
u = member.avatar_url
url = process_avatar(u)
embed = discord.Embed(description=avatar.format(author, mention), colour=discord.Colour.blue())
embed.set_image(url=u)
await self.bot.say(embed=embed)
我正在努力的代码行是这一行
if role in member.roles:
pa = "This members avatar is private"
await self.bot.say(pa)
return
这应该基本上输出消息“此成员头像是私人的”而不检索头像,但它仍然会检索带有消息的头像。
非常感谢您的帮助。
【问题讨论】:
标签: python python-3.x discord.py