【问题标题】:I can't get the list of all the members in a guild discord.py我无法获得公会 discord.py 中所有成员的列表
【发布时间】:2021-12-03 22:27:25
【问题描述】:

我正在尝试打印我的机器人所在的所有服务器中所有成员的所有名称。 这是我的代码:

@bot.event
async def on_ready():
    await bot.wait_until_ready()
    for guild in bot.guilds:
        print(guild.name)
        for member in guild.members:
            print(member.name)

这会打印所有公会名称,但只打印机器人自己的名称,我该如何解决这个问题?

【问题讨论】:

标签: python discord discord.py


【解决方案1】:

将此代码添加到您的机器人:

intents = discord.Intents.default()
intents.members = True

bot = commands.Bot(..., intents=intents)

获取会员信息:

文档:https://discordpy.readthedocs.io/en/master/api.html#intents

【讨论】:

  • 提供没有解释的代码是没有帮助的。还请解释一下,提供激活意图的链接等 - 这里缺少一些东西。
  • 我编辑它并为你添加一个有用的链接
猜你喜欢
  • 2020-11-11
  • 2019-12-29
  • 2021-03-14
  • 1970-01-01
  • 2021-12-17
  • 2021-08-18
  • 2021-02-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多