0

So I've tried this code, but I can't figure out why it isn't working. It only sends my bot name instead of sending all the users in my server

@bot.event
async def on_message(message) :    
 if message.content.startswith('?users'):
    guild = bot.get_guild(server id there)
    print(", ".join([member.name for member in message.guild.members]))
  • 1
    Does this post 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) – ObjectJosh Mar 31 '21 at 21:26
  • yes but when I run the bot, it only prints TestBot#7217 even if there are 1k members in my server. How can I loop it in order to get all the users name? –  Mar 31 '21 at 21:32
  • You have to enable intents, take a look at: https://discordpy.readthedocs.io/en/latest/intents.html?highlight=intents – Łukasz Kwieciński Mar 31 '21 at 22:09

0 Answers0