Discord.py - How to get member count not including bots?

I want to make a command that shows member count but not including bots. My code:

@bot.command()
async def members(ctx):
    await ctx.send(f"Members in {ctx.guild.name}: {ctx.guild.member_count}")

However this shows count of bots and members together. Is there a way I can do it show members only?


Solution 1:

You can try something like this,

user_count = len([x for x in ctx.guild.members if not x.bot])