我正在尝试使用discord.py生成discord服务器中所有成员的列表。这是我的代码:
import discord
from discord.ext import commands
class Events(commands.Cog):
def __init__(self, client):
self.client = client
def get_member_names(self):
for guild in self.client.guilds:
for member in guild.members:
yield member.name
@commands.Cog.listener()
async def on_ready(self):
await self.client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching,
name="the Chat."))
print('Bot has logged in as {0.user.name}'.format(self.client))
people = set(self.get_member_names())
print(people)
def setup(client):
client.add_cog(Events(client))
问题是我只在服务器中得到Bot的名称,而没有任何用户,如何解决?