Skip to content
Advertisement

Print online users to console, Discord.py

When I execute the command using my current code, I get the error NameError: name 'offline' is not defined. I can’t find the correct variables to make it work properly.

@bot.command()
async def D(ctx):
    for user in ctx.guild.members:
        if user.status != offline:
            print (user.name+"#"+user.discriminator)

Advertisement

Answer

According to the API reference, you could use

if user.status != discord.Status.offline

PS. I know nothing about this library, yet I tried searching the docs. Give it a try from now on :)

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement