无法迭代服务器不协调API的成员
当我运行这段代码时,它只返回两次bot名称。服务器有两个成员,我自己和bot。我需要遍历服务器的每个成员。我做错了什么?您只是没有启用无法迭代服务器不协调API的成员,api,loops,discord.py,Api,Loops,Discord.py,当我运行这段代码时,它只返回两次bot名称。服务器有两个成员,我自己和bot。我需要遍历服务器的每个成员。我做错了什么?您只是没有启用意图。成员 intents=discord.intents.default() intents.members=True client=commands.Bot(command_prefix=“:”,intents=intents) 还要确保在中启用它们 参考: 哎呀,我真傻。非常感谢你的回答!!!现在开始工作了 import discord import
意图。成员
intents=discord.intents.default()
intents.members=True
client=commands.Bot(command_prefix=“:”,intents=intents)
还要确保在中启用它们
参考:
import discord
import asyncio
from discord.ext import commands
client = commands.Bot(command_prefix=':')
token = ''
@client.event
async def on_ready():
print('BOT ONLINE')
@client.event
async def on_message(message):
channel = message.channel
if message.content.startswith('/'):
if message.content.startswith("/users"):
# FOR LOOP IN QUESTION ---------------
for guild in client.guilds:
for member in guild.members:
print(member) # or do whatever you wish with the member detail
client.run(token)
print("Bot Finished")