-
So I am trying to get the members inside a background task function. But I don't seem to get the correct count. Here is the code @loop(minutes=10)
async def reached_milestone(self):
with sqlite3.connect('db.sqlite3') as db:
cursor = db.execute("SELECT * FROM Milestones")
values = cursor.fetchall()
for value in values:
guildid, members = value
guild = await self.client.fetch_guild(guildid)
print(len(guild.members))
member_count = len(
[member for member in guild.members if not member.bot])
if member_count >= members:
channel = read_database(guild.id)
print(channel) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Beta Was this translation helpful? Give feedback.
-
You can also member_count for an estimated member_count, it works pretty well with intents.member, or hopefully when prescence_count gets added(exists in api, but not in the actual library) then that too, soon |
Beta Was this translation helpful? Give feedback.
-
hi |
Beta Was this translation helpful? Give feedback.
fetch_guild
does not return member data. Useget_guild
instead and this’ll work just fine (given that you have themembers
intent.