Answer the question
In order to leave comments, you need to log in
How to fix syntax error when aggregating (mongodb discord.py)?
I'm trying to create a command that displays a specific field of a random document in a collection:
@client.command()
async def name(ctx):
db = cluster['dbname']
collection = db['collname']
await ctx.send(embed = discord.Embed(description = f"{collection.aggregate({$sample : {size:1}})['fieldname']}"))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question