【问题标题】:How do I get a list of all of the members in a discord server using discord.py如何使用 discord.py 获取不和谐服务器中所有成员的列表
【发布时间】:2020-12-04 00:08:15
【问题描述】:

我正在尝试生成我服务器中所有成员的列表:

@client.event
async def on_ready():
    for guild in client.guilds:
        for member in guild.members:
            print(member)

但是它只打印自己,而不打印其他成员。我写错了什么还是我需要对机器人做些什么?

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    您需要启用intents.members

    intents = discord.Intents.default()
    intents.members = True
    
    client = commands.Bot(..., intents=intents)
    # Or if you're using `discord.Client`
    client = discord.Client(intents=intents)
    

    还要确保在 developer portal 中启用它们

    docs

    【讨论】:

      猜你喜欢
      • 2019-10-24
      • 2018-05-23
      • 2020-11-27
      • 1970-01-01
      • 1970-01-01
      • 2021-11-18
      • 2021-08-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多