1

I'm currently trying to print all the online and dnd users from my server and I'm getting this error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: 'property' object is not iterable

This is the code:

@bot.command()
async def status(ctx):
    for member in message.Guild.members:
        if (member.status == discord.Status.online or member.status == discord.Status.dnd) and not member.bot:
            print(member)
RiveN
  • 2,595
  • 11
  • 13
  • 26
ASV
  • 13
  • 2
  • Do you have the [presence](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.presences) and [members](https://discordpy.readthedocs.io/en/stable/api.html#discord.Intents.members) [privileged intents](https://stackoverflow.com/questions/64831017/how-do-i-get-the-discord-py-intents-to-work) activated? – TheFungusAmongUs Jan 27 '22 at 06:30

1 Answers1

1

according to the API

@bot.command()
async def D(ctx):
    for user in ctx.guild.members:
        if user.status != discord.Status.offline
            print (user.name+"#"+user.discriminator)
Tal Folkman
  • 2,368
  • 1
  • 7
  • 21
  • For some reason it's not printing any of the users. If I try printing the users before the "if" it's only giving me the bot name and tag, if I try and print out before the "if" it doesn't print anything. There were >30 online users within the server when I tested the bot. – ASV Jan 26 '22 at 13:45
  • Edit : After adding the necessary intents as TheFungusAmongUs said the code now works, thanks a lot you guys :D – ASV Jan 27 '22 at 11:37