0

main.py

import discord
import os
from kmf import playkmf

client = discord.Client()

@client.event
async def on_ready():
    print('We have logged in as {0.user}'.format(client))


@client.event
async def on_message(message):
    if message.author == client.user:
        return 
    
    if message.content.startswith('-='):

        if message.content == '-= playkmf':
            await playkmf(message)
        else :
            await message.channel.send("type -=help for help")


client.run(os.getenv('TOKEN'))

kmf.py

async def playkmf(message) :
    allMembers = message.guild.members
    for x in allMembers:
        print(x.name)
    await message.channel.send('KMF started')

output when i type "-= playkmf" in the console

We have logged in as JujuGames#6518
JujuGames

There are 5 member in the discord server. The output is showing only 1 member.

Varun Pandey
  • 80
  • 2
  • 5
  • Does this answer your question? [How do I get a list of all members in a discord server using the new discord.py version?](https://stackoverflow.com/questions/56519760/how-do-i-get-a-list-of-all-members-in-a-discord-server-using-the-new-discord-py) – Captain Trojan Feb 06 '21 at 17:25
  • I have already tried that method @CaptainTrojan. I am still getting the same issue, it is only printing one name. – Varun Pandey Feb 07 '21 at 07:20

0 Answers0