Querying the member_count property on a discord.guild.Guild object gives the error AttributeError("'Guild' object has no attribute '_member_count'") #2136
Querying the member_count property on a discord.guild.Guild object gives the error AttributeError("'Guild' object has no attribute '_member_count'")
Reproduction Steps
Query the member_count property on a discord guild object, like shown in the code below
Minimal Reproducible Code
from discord.ext import commands
import discord
from rich import inspect
import json
# Loads the config
with open('config.json') as f:
config:dict = json.load(f)
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(intents=intents)
@bot.event
async def on_ready():
# Get info of all the guilds
async for guild in bot.fetch_guilds():
actual_guild = await bot.fetch_guild(guild.id, with_counts=True)
inspect(actual_guild)
print(actual_guild.member_count)
await bot.close()
bot.run(config['token'])
Expected Results
The count of members to be shown
Actual Results
It raised an error. This is the output:
Intents
the default ones and the member one
System Information
- Python v3.11.3-final
- py-cord v2.4.1-final
- aiohttp v3.8.4
- system info: Darwin 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64
Checklist
[X] I have searched the open issues for duplicates.
[X] I have shown the entire traceback, if possible.
[X] I have removed my token from display, if visible.
If you use fetch_guild, you should be using Guild.approximate_member_count
That being said, this can still be considered a bug as the attribute should be set regardless.
Summary
Querying the member_count property on a discord.guild.Guild object gives the error AttributeError("'Guild' object has no attribute '_member_count'")
Reproduction Steps
Query the
member_count
property on a discord guild object, like shown in the code belowMinimal Reproducible Code
Expected Results
The count of members to be shown
Actual Results
It raised an error. This is the output:
Intents
the default ones and the member one
System Information
Checklist
Additional Context
No response