Discord Bot - 公会成员显示在计数中......但不在 guild.members [英] Discord Bot - Guild Members Showing in count... but not in guild.members

查看:15
本文介绍了Discord Bot - 公会成员显示在计数中......但不在 guild.members的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法让我的不和谐机器人列出它添加到的唯一公会的所有成员..

having trouble getting my discord bot to list all the members of the only guild it's added to..

async def on_ready(self):
    print("logged in as {0}".format(self.user))
    
    guilds = self.guilds        
    print("guilds: " + str(guilds))

    guild = self.get_guild(my_guild_id)
    print("guild members: " + str(guild.members))

有趣的是,当我打印出公会本身时,它显示的成员数为 5(这是正确的).但是,当实例化 Guild 对象并访问 members 属性时,它只会将 bot 用户本身显示为成员.

The interesting thing is that when i print out the guild itself it shows a member count of 5 (which is correct). However when instantiate the Guild object, and access the members property, it only shows the bot user itself as the member.

guild members: [<Member id=12345678 name='testapp1_bot' discriminator='0683' bot=True nick=None guild=<Guild id=12345 name="ethandrower's server" shard_id=None chunked=False member_count=5>>]
guilds: [<Guild id=12345 name="ethandrower's server" shard_id=None chunked=False member_count=5>]

我猜这要么是我对公会"架构的误解,要么是对机器人事物的权限.我已将机器人添加到具有完全管理员访问权限的服务器,所以我有点困惑为什么我可以看到正确的成员数量,但看不到 Member 对象本身?

I'm guessing this either my misunderstanding of the architecture of 'guilds' or a permissions on the bot thing. I've added the bot to the server with full administrator access, so I'm a little stumped as to why I can see the proper count of members, but not the Member objects themselves?

任何帮助将不胜感激!

推荐答案

如果您使用的是最新版本的 discord.py 即 1.5.0,则需要启用 Member intent 并将其应用到您的机器人.

If you're using the latest version of discord.py i.e. 1.5.0, you will need to enable Member intent and apply it to your bot.

p>

如何启用会员意图:https://discordpy.readthedocs.io/en/latest/intents.html#privileged-intents

阅读有关 Intent 的更多信息:https://discordpy.readthedocs.io/en/最新/intents.html

Read More about Intents: https://discordpy.readthedocs.io/en/latest/intents.html

这篇关于Discord Bot - 公会成员显示在计数中......但不在 guild.members的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆