如何找出一个人是否有 Nitro 不和谐,我是使用用户。public_flags.all但没有检测到 Nitro。我可以用什么来得到它。请帮忙!
await ctx.send(user.public_flags.all())
我看到配置文件但不工作我使用 discord.py.Python 是 3.8 .Windows 10
如何找出一个人是否有 Nitro 不和谐,我是使用用户。public_flags.all但没有检测到 Nitro。我可以用什么来得到它。请帮忙!
await ctx.send(user.public_flags.all())
我看到配置文件但不工作我使用 discord.py.Python 是 3.8 .Windows 10
简单的回答:你不能。
但在大多数情况下,nitro 用户使用动画头像、提升服务器或使用诸如#0001
、#9999
、之类的鉴别#6969
器。
你应该知道,没有硝基的用户也可以有这种鉴别器,但它非常罕见。
所以你可以检查所有这些。
@bot.command()
async def check_nitro(ctx):
has_nitro = False
# Check if the User boosts the guild
if ctx.author.premium_since is not None:
has_nitro = True
# Check if the user has an animated profile picture
if ctx.author.avatar_url is not None:
if ctx.author.is_avatar_animated():
has_nitro = True
# check for discriminators like #0001 or #9999 or #6969
# You should know that users without nitro can have this discriminators too, but its very rare.
if ctx.author.discriminator in ("0001", "9999", "6969"):
has_nitro = True
if has_nitro is True:
await ctx.reply("User has nitro!")
else:
await ctx.reply("User doesn't have nitro!")
改为使用user.profile().nitro
。
您可以将user
参数作为discord.User
对象传递:
@Bot.command()
async def foo(ctx, user: discord.User): # Not discord.Member
pass
如果我理解得很好,最新版本的 Discord.py 使用User.Profile
而不是User.profile()
.
然后,还要检查这个,关于类的 API 参考discord.Profile
。
类具有带别名discord.Profile
的属性。这将返回一个..premium
.nitro
bool
你不能用机器人来做到这一点。