How To Separate Bot's From Members In Member_count?
During a command that displays the member count of the server, i'd like to separate the number of bots from the number of human members and display them each. I can output the total number of members in the server but i'm not sure how to get the bot to distinguish a bot user from human user.
if message.content.startswith('<count'): channel = message.channel members = message.guild.member_count msg = discord.Embed(title="Amount of members in this Discord:", description=members, color=0x0000ff) await channel.send(embed=msg)
How would I separate the bot users from the count and display that number separately?
Didn't really find anything specific in the Discordpy documentation that allows fetching of members.
So I decided to get the entire list of members in the server instead and filter the list by bots.
if message.content.startswith('<count'): membersInServer = message.guild.members # Filter to the list, returns a list of bot-members botsInServer = list(filter(filterOnlyBots, membersInServer)) botsInServerCount = len(botsInServer) # (Total Member count - bot count) = Total user count usersInServerCount = message.guild.member_count - botsInServerCount # Whatever you want to do with the count here # Put this function somewhere... # Filter the member list to only bots def filterOnlyBots(member): return member.bot
Speed/performance might be a downside as the server gets larger (more members), hopefully someone posts a better solution than mine.
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module