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

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

问题描述

让我的不和谐机器人列出添加到它的唯一公会的所有成员时遇到了麻烦.

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对象并访问member属性时,它仅将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>]

我猜这可能是我对行会"架构的误解或对机器人事物的许可.我已将该漫游器添加到具有完全管理员访问权限的服务器中,所以对于为什么我可以看到适当数量的成员而不是成员对象本身感到有些困惑,我对此感到有些困惑?

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),则需要启用成员意图并将其应用于您的机器人.

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.

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

了解更多有关意图的信息: https://discordpy.readthedocs.io/en/Latest/intents.html

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

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

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