如何找出一个人是否有硝基不和谐

2024-06-16 10:11:06 发布

您现在位置:Python中文网/ 问答频道 /正文

如何找出一个人是否有Nitro不和谐,我是use用户。公共标志。全部,但不检测硝基。 我能用什么来得到它。请帮忙! await ctx.send(user.public_flags.all())

我看到个人资料但不起作用 我使用discord.py.Python是3.8.Windows10


Tags: 用户pysenduse标志publicallawait
2条回答

硝化甘油


改用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()

侧面图


然后,还要检查this,关于类discord.Profile的API引用。
discord.Profile具有别名为.nitro的属性.premium。这将返回一个bool

不可能


你不能用机器人来做这件事

简单回答:你不能


但在大多数情况下,nitro用户使用动画配置文件图片、增强服务器或使用类似#0001#9999#6969之类的鉴别器

您应该知道,没有nitro的用户也可以使用此鉴别器,但其非常罕见

所以你可以检查所有这些

@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!")

来源

Member Documentation

相关问题 更多 >