I am trying to generate a list of all of the members in a discord server using discord.py. Here is my code:
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))
The problem is that I get only the Name of the Bot in the server but not any of the users, how to fix that?
async defand not justdef- Remi_Zachariasget_member_namesdoesn't useawaitorasync forso making itasync defis not required - unex