【问题标题】:how to find out if a person has nitro discord py [closed]如何确定一个人是否有 nitro discord py [关闭]
【发布时间】:2021-09-12 16:07:01
【问题描述】:

如何确定一个人是否有 Nitro 不和谐,我使用的是 用户。 public_flags.all 但没有检测到 Nitro。 我可以用什么来得到它。请帮忙! await ctx.send(user.public_flags.all())

我看到了个人资料,但没用 我使用 discord.py.Python 是 3.8 .Windows 10

【问题讨论】:

  • “我看到个人资料但不工作”是什么意思?因为Profile 是你看到它的地方。
  • 我在问你对don't work 的意思,例如“什么不起作用”。编辑。好吧,我知道它已被弃用,将它放在您的帖子中会更清楚。在那种情况下,你再也看不到它了。
  • 配置文件不起作用,因为它仅适用于用户帐户而不适用于机器人帐户。使用用户令牌登录和与用户机器人相关的内容在 1.7 及更高版本中已弃用

标签: python python-3.x discord discord.py


【解决方案1】:

简单回答:你不能。


但在大多数情况中,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!")

来源

Member Documentation

【讨论】:

  • 非常糟糕的主意。如果用户真的有#0001 标签怎么办?例如我的第一个帐户有 #9999 没有使用硝基,你的机器人每天都会给我高级命令?
  • 我编辑了我的答案,以添加此信息。谢谢。
  • @FLAK-ZOSO 这是最好的方法。不要只说非常糟糕的主意,请提供一个适用于机器人的好主意
【解决方案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 具有属性 .premium,别名为 .nitro。这将返回一个bool。

不可能


你不能用机器人来做到这一点。

【讨论】:

  • AttributeError: 'Member' 对象没有属性 'profile'\
  • @НикитаДавыдов,也许您必须将成员作为 discord.User 对象而不是作为 discord.Member 对象传递
  • @client.command() async def tests(ctx,user: discord.User): await ctx.send(user.profile().nitro) 是吗?
  • @НикитаДавыдов,是的。
  • discord.ext.commands.errors.CommandInvokeError: 命令引发异常:AttributeError: 'User' object has no attribute 'profile'
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-01-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-24
相关资源
最近更新 更多