discord.py获得在线会员
我正在尝试通过此代码获得所有在线会员(带有机器人):
@client.command() async def printstats(ctx):
#define the variables
oc = 0
for user in ctx.guild.members:
if user.status != discord.Status.offline:
oc+=1
但是,尽管我得到的一切都是1号,即使在线有200名成员。 我已经搜索了整个Internet AMD无法找到有效的解决方案。请你帮助我好吗?
I'm trying to get all online members (with Bots) via this Code:
@client.command() async def printstats(ctx):
#define the variables
oc = 0
for user in ctx.guild.members:
if user.status != discord.Status.offline:
oc+=1
However, all as I get a result, is the number 1, even though there are 200 members online.
I already searched through the whole internet amd couldn't find a solution that worked. Could you please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您之所以存在此问题,是因为您的机器人没有使用存在意图,因此,机器人只能将自己视为在线,而没有其他用户,因此值为1。要解决此问题,您需要:
You have this issue because your bot is not using the presence intent, hence the bot can only see itself as online, and no other users, hence the value of 1. To fix this, you need to: