【问题标题】:Discord bot not seeing guild members and new members joining [duplicate]Discord bot没有看到公会成员和新成员加入[重复]
【发布时间】:2021-06-18 17:01:24
【问题描述】:

我无法让我的不和谐机器人在 python 中查看公会成员(除了它自己)或在新成员加入时触发操作。

import os

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

from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')

client = discord.Client()

@client.event
async def on_ready():
    for guild in client.guilds:
        print(
            f'{client.user} is connected to the following guild:\n'
            f'{guild.name}(id: {guild.id})'
        )
        for member in guild.members:
            print(
                f'{member.name}'
            )

@client.event
async def on_member_join(member):
    print(f'Someone has joined the server.')

client.run(TOKEN)

机器人在公会中有管理员权限。 我已在机器人页面上启用所有特权意图。

运行时可以看到公会中有三个成员(guild.member_count),但只列出了自己。如果成员离开并重新加入,它绝对不会做任何事情。

【问题讨论】:

    标签: discord.py


    【解决方案1】:

    那是因为你没有将意图传递给 Client()

    client = discord.Client(intents=intents)
    

    【讨论】:

      猜你喜欢
      • 2021-07-19
      • 2021-01-20
      • 2021-07-05
      • 1970-01-01
      • 2021-06-25
      • 2021-01-23
      • 2021-06-06
      • 2021-10-11
      • 2021-02-15
      相关资源
      最近更新 更多